Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://stackoverflow.com/questions/23041021/how-to-write-some-data-to-excel-file-xlsx
- using NPOI.SS.UserModel;
- using NPOI.XSSF.UserModel;
- namespace MacroUCS.Backend
- {
- class Sample
- {
- public void SampleFunction()
- {
- IWorkbook workbook = new XSSFWorkbook();
- ISheet sheet1 = workbook.CreateSheet("Sheet1");
- IRow row1 = sheet1.CreateRow(0);
- row1.CreateCell(0).SetCellValue("Name");
- row1.CreateCell(1).SetCellValue("Age");
- row1.CreateCell(2).SetCellValue("City");
- IRow row2 = sheet1.CreateRow(1);
- row2.CreateCell(0).SetCellValue("Ben");
- row2.CreateCell(1).SetCellValue("20");
- row2.CreateCell(2).SetCellValue("xyz");
- IRow row3 = sheet1.CreateRow(2);
- row3.CreateCell(0).SetCellValue("Jack");
- row3.CreateCell(1).SetCellValue("25");
- row3.CreateCell(2).SetCellValue("xyz");
- IRow row4 = sheet1.CreateRow(3);
- row4.CreateCell(0).SetCellValue("Mike");
- row4.CreateCell(1).SetCellValue("45");
- row4.CreateCell(2).SetCellValue("zyx");
- FileStream sw = File.Create("work1_4.13.14.xlsx");
- workbook.Write(sw, true);
- sw.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement