public void SaveExcel()
{
try
{
FileStream fwriter = new FileStream("c:\\ss.xlsx",FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
MemoryStream file = new MemoryStream();
workbook.Write(file);
file.WriteTo(fwriter);
}
catch (Exception)
{
throw;
}
}
void InitializeWorkbook() {
workbook = new HSSFWorkbook();
////create a entry of DocumentSummaryInformation
DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
dsi.Company = "NPOI Team";
workbook.DocumentSummaryInformation = dsi;
////create a entry of SummaryInformation
SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
si.Subject = "NPOI SDK Example";
workbook.SummaryInformation = si;
worksheet = workbook.CreateSheet("Sheet1");
}
public void AddData(int row, int col, string data)//, string format)
{
try
{
worksheet.CreateRow(row).CreateCell(col).SetCellValue(data);
}
catch (Exception)
{
throw;
}
}