public void ExportBigData() { AvrDataTable data = CreateBigData(30, 100000); string fileName = Path.GetTempPath() + "testBig.xls"; using (var npoiExcelWrapper = new NpoiExcelWrapper(ExportType.Xls)) { npoiExcelWrapper.Export(fileName, data); Assert.IsTrue(File.Exists(fileName)); } fileName = Path.GetTempPath() + "testBig1.xlsx"; using (var npoiExcelWrapper = new NpoiExcelWrapper(ExportType.Xlsx)) { npoiExcelWrapper.Export(fileName, data); Assert.IsTrue(File.Exists(NpoiExcelWrapper.AppendFileNameWithSuffix(fileName, "1"))); Assert.IsTrue(File.Exists(NpoiExcelWrapper.AppendFileNameWithSuffix(fileName, "2"))); Assert.IsTrue(File.Exists(NpoiExcelWrapper.AppendFileNameWithSuffix(fileName, "3"))); Assert.IsTrue(File.Exists(NpoiExcelWrapper.AppendFileNameWithSuffix(fileName, "4"))); } }
public void Export() { AvrDataTable data = CreateData(); AccessTests.RemoveCopyColumns(data); string fileName = Path.GetTempPath() + "test.xls"; using (var npoiExcelWrapper = new NpoiExcelWrapper(ExportType.Xls)) { npoiExcelWrapper.Export(fileName, data); Assert.IsTrue(File.Exists(fileName)); for (int j = 0; j < data.Columns.Count; j++) { Assert.AreEqual(data.Columns[j].Caption, npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(0).GetCell(j).StringCellValue); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(data.Rows[j][0], npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(0).StringCellValue); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(((DateTime)data.Rows[j][1]).Date, npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(1).DateCellValue.Date); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(data.Rows[j][2], Convert.ToInt32(npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(2).NumericCellValue)); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(data.Rows[j][3], npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(3).NumericCellValue); } } fileName = Path.GetTempPath() + "test.xlsx"; using (var npoiExcelWrapper = new NpoiExcelWrapper(ExportType.Xlsx)) { npoiExcelWrapper.Export(fileName, data); Assert.IsTrue(File.Exists(fileName)); for (int j = 0; j < data.Columns.Count; j++) { Assert.AreEqual(data.Columns[j].Caption, npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(0).GetCell(j).StringCellValue); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(data.Rows[j][0], npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(0).StringCellValue); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(((DateTime)data.Rows[j][1]).Date, npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(1).DateCellValue.Date); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(data.Rows[j][2], Convert.ToInt32(npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(2).NumericCellValue)); } for (int j = 0; j < data.Rows.Count; j++) { Assert.AreEqual(data.Rows[j][3], npoiExcelWrapper.Workbook.GetSheetAt(0).GetRow(j + 1).GetCell(3).NumericCellValue); } } //fileName = Path.GetTempPath() + "test1.xlsx"; //using (var npoiExcelWrapper = new ClosedXmlExcelWrapper()) //{ // npoiExcelWrapper.Export(fileName, data); // Assert.IsTrue(File.Exists(fileName)); //} }