-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.cs
More file actions
77 lines (68 loc) · 2.29 KB
/
Copy pathprogram.cs
File metadata and controls
77 lines (68 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.IO;
namespace Exceltesting
{
class Program
{
static void Main(string[] args)
{
string filename;
double[] intArray;
int i, q=0;
double s;
intArray = new double[25];
for (i = 0; i < 25;i++ ) intArray[i] = 0;
while (true)
{
q++;
filename = "C:\\Testing\\" + q.ToString();
filename += ".xlsx";
XSSFWorkbook workbook = new XSSFWorkbook();
FileStream file2 = new FileStream(@filename, FileMode.Open, FileAccess.Read);
if (file2 == null) break;
workbook = new XSSFWorkbook(file2);
ISheet sheet = workbook.GetSheet("Sheet1");
IRow row ;
for (i = 1; i < 22; i++)
{
row = sheet.GetRow(i);
if (row != null)
{
s = 0;
Console.WriteLine(row.GetCell(2).ToString());
for (int j = 3; j < row.LastCellNum; j++)
{
string temp = row.GetCell(j).ToString();
try
{
s += Convert.ToDouble(temp);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
intArray[i] += s;
Console.WriteLine(intArray[i]);
}
}
for (i=1;i<22;i++)
{
row = sheet.GetRow(i);
Console.Write(row.GetCell(2));
double t = intArray[i] / 17;
Console.WriteLine("{0:F1}",t);
}
file2.Close();
workbook.Close();
Console.ReadLine();
}
}
}
}