Using c#, npoi
Basically I used npoi to create and export data to an excel sheet but I'm open to other ways other than npoi to fix it. The data still exports as intended but when I try to print using excel, the sheet looks like below. I want to fix it directly in the code so what went wrong?
dataRow = (HSSFRow)sheet.CreateRow(31);
dataRow.CreateCell(0).SetCellValue("Name");
dataRow.GetCell(0).CellStyle = fontmaintoprightbotleft;
for (int i = 1; i < 14; i++) //this only puts the border on top of the undeclared cells
{
dataRow.CreateCell(i).CellStyle = fontmaintoprightbotleft;
}
cra = new NPOI.SS.Util.CellRangeAddress(31, 31, 0, 5);
sheet.AddMergedRegion(cra);
dataRow.CreateCell(6).SetCellValue("Contact No. (Hp)");
dataRow.GetCell(6).CellStyle = fontmaintoprightbotleft;
cra = new NPOI.SS.Util.CellRangeAddress(31, 31, 6, 8);
sheet.AddMergedRegion(cra);
dataRow.CreateCell(9).SetCellValue("Relationship");
dataRow.GetCell(9).CellStyle = fontmaintoprightbotleft;
cra = new NPOI.SS.Util.CellRangeAddress(31, 31, 9, 13);
sheet.AddMergedRegion(cra);
dataRow = (HSSFRow)sheet.CreateRow(32);
dataRow.CreateCell(0).SetCellValue(EmergNametxt.Text);
dataRow.GetCell(0).CellStyle = fontmaintoprightbotleft; //this only puts the border on top of the undeclared cells
for (int i = 1; i < 14; i++)
{
dataRow.CreateCell(i).CellStyle = fontmaintoprightbotleft;
}
cra = new NPOI.SS.Util.CellRangeAddress(32, 32, 0, 5);
sheet.AddMergedRegion(cra);
dataRow.CreateCell(6).SetCellValue(EmergContactNoTextBox.Text);
dataRow.GetCell(6).CellStyle = fontmaintoprightbotleft;
cra = new NPOI.SS.Util.CellRangeAddress(32, 32, 6, 8);
sheet.AddMergedRegion(cra);
dataRow.CreateCell(9).SetCellValue(EmergRelationshiptxt.Text);
dataRow.GetCell(9).CellStyle = fontmaintoprightbotleft;
cra = new NPOI.SS.Util.CellRangeAddress(32, 32, 9, 13);
sheet.AddMergedRegion(cra);
dataRow = (HSSFRow)sheet.CreateRow(33);
dataRow.CreateCell(0).SetCellValue("Education Profile");
for (int i = 1; i < 14; i++)
{
dataRow.CreateCell(i).CellStyle = fontheader;
}
dataRow.GetCell(0).CellStyle = fontheader;
cra = new NPOI.SS.Util.CellRangeAddress(33, 33, 0, 13);
sheet.AddMergedRegion(cra);
dataRow = (HSSFRow)sheet.CreateRow(34);