Skip to content

Commit 2dff6b3

Browse files
committed
Export-To-Excel-Updated
1 parent 9feb0ca commit 2dff6b3

File tree

62 files changed

+1196
-1283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1196
-1283
lines changed
Binary file not shown.
Binary file not shown.

Export-Array-to-Excel/.vs/Export-Array-to-Excel/v15/Server/sqlite3/db.lock

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

Export-Array-to-Excel/Export-Array-to-Excel/Program.cs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,39 @@ class Program
88
{
99
static void Main(string[] args)
1010
{
11-
try
11+
12+
using (ExcelEngine excelEngine = new ExcelEngine())
1213
{
13-
using (ExcelEngine excelEngine = new ExcelEngine())
14-
{
15-
IApplication application = excelEngine.Excel;
16-
application.DefaultVersion = ExcelVersion.Excel2016;
14+
IApplication application = excelEngine.Excel;
15+
application.DefaultVersion = ExcelVersion.Xlsx;
1716

18-
//Reads input Excel stream as a workbook
19-
IWorkbook workbook = application.Workbooks.Open(File.OpenRead(Path.GetFullPath(@"../../../Expenses.xlsx")));
20-
IWorksheet sheet = workbook.Worksheets[0];
17+
//Reads input Excel stream as a workbook
18+
IWorkbook workbook = application.Workbooks.Open(File.OpenRead(Path.GetFullPath(@"../../../Expenses.xlsx")));
19+
IWorksheet sheet = workbook.Worksheets[0];
2120

22-
//Preparing first array with different data types
23-
object[] expenseArray = new object[14]
24-
{"Paul Pogba", 469.00d, 263.00d, 131.00d, 139.00d, 474.00d, 253.00d, 467.00d, 142.00d, 417.00d, 324.00d, 328.00d, 497.00d, "=SUM(B11:M11)"};
21+
//Preparing first array with different data types
22+
object[] expenseArray = new object[14]
23+
{"Paul Pogba", 469.00d, 263.00d, 131.00d, 139.00d, 474.00d, 253.00d, 467.00d, 142.00d, 417.00d, 324.00d, 328.00d, 497.00d, "=SUM(B11:M11)"};
2524

26-
//Inserting a new row by formatting as a previous row.
27-
sheet.InsertRow(11, 1, ExcelInsertOptions.FormatAsBefore);
25+
//Inserting a new row by formatting as a previous row.
26+
sheet.InsertRow(11, 1, ExcelInsertOptions.FormatAsBefore);
2827

29-
//Import Peter's expenses and fill it horizontally
30-
sheet.ImportArray(expenseArray, 11, 1, false);
28+
//Import Peter's expenses and fill it horizontally
29+
sheet.ImportArray(expenseArray, 11, 1, false);
3130

32-
//Preparing second array with double data type
33-
double[] expensesOnDec = new double[6]
34-
{179.00d, 298.00d, 484.00d, 145.00d, 20.00d, 497.00d};
31+
//Preparing second array with double data type
32+
double[] expensesOnDec = new double[6]
33+
{179.00d, 298.00d, 484.00d, 145.00d, 20.00d, 497.00d};
3534

36-
//Modify the December month's expenses and import it vertically
37-
sheet.ImportArray(expensesOnDec, 6, 13, true);
35+
//Modify the December month's expenses and import it vertically
36+
sheet.ImportArray(expensesOnDec, 6, 13, true);
3837

39-
//Save the file in the given path
40-
Stream excelStream = File.Create(Path.GetFullPath(@"Output.xlsx"));
41-
workbook.SaveAs(excelStream);
42-
excelStream.Dispose();
43-
}
44-
}
45-
catch (Exception e)
46-
{
47-
Console.WriteLine("Unexpected Exception:"+e.Message);
38+
//Save the file in the given path
39+
Stream excelStream = File.Create(Path.GetFullPath(@"Output.xlsx"));
40+
workbook.SaveAs(excelStream);
41+
excelStream.Dispose();
4842
}
43+
4944
}
5045
}
5146
}
Binary file not shown.

Export-CSV-to-Excel/.vs/Export-CSV-to-Excel/v15/Server/sqlite3/db.lock

Whitespace-only changes.

0 commit comments

Comments
 (0)