I need to export data into Excel, but need to use a template (.xls file) that has other content as well.
When I insert rows into the excel file (in between where i need to set the data that i'm exporting) and try to set the borders for the rows (cellstyle), I just don't see the borders for the rows that I set the style to, but instead entire generated excel
has the cellstyle changed to the border that I'm setting. Following is my code.
myPath = string.Concat(Server.MapPath("~"), myPath, "RFQ_Costed_BOM.xls");
NPOI.HSSF.UserModel.HSSFWorkbook workbook = new NPOI.HSSF.UserModel.HSSFWorkbook();
FileStream fs = new FileStream(myPath, FileMode.Open, FileAccess.Read);
workbook = new HSSFWorkbook(fs, true);
worksheet = (HSSFSheet)workbook.GetSheetAt(0);
for (int j = iExcelRow; j < iExcelRow + iRows; j++)
HSSFRow row = (HSSFRow)worksheet.CreateRow(j);
for (int l = 0; l < 12; l++)
HSSFCell cell = (HSSFCell)row.CreateCell(l);
cell.CellStyle.BorderBottom = NPOI.SS.UserModel.CellBorderType.THIN;
Keen to know what might be going wrong.