After that I am getting some data from a database, and using the same InsertArray method to insert the data in the worksheet. This data has some empty ( like this: "") elements.
When I am saving the Workbook to a file, all the empty data is replaced by the value of the cell A1. (Please, see the code I am using, and the screenshot).
It looks like the file generation replaces the empty cells with the cell A1 value.
How can I solve this problem?
Thanks!!
- Code: Select all
ReportOutputFile = new Workbook();
ReportOutputFile.Worksheets[0].Name = "New name";
string[] columnTitles = new string[]
{
"Column 1",
"Column 2",
"Column 3",
"Column 4",
"Column 5",
"Column 6",
"Column 7",
"Column 8",
"Column 9",
"Column 10",
"Column 11",
"Column 12",
"Column 13",
"Column 14",
"Column 15",
"Column 16",
"Column 17",
"Column 18",
"Column 19",
"Column 20",
"Column 21",
"Column 22",
"Column 23",
"Column 24",
"Column 25",
"Column 26",
"Column 27",
"Column 28",
"Column 29",
"Column 30"
};
ReportOutputFile.Worksheets[0].InsertArray(columnTitles, 1, 1, false);
List<DataModel> datalList = dbConnection.GetData();
var line = 2;
datalList.ForEach(_ =>
{
ReportOutputFile.Worksheets[0].InsertArray(_.ToArray(), line, 1, false); //Some elements of the list have empty values for some properties
line++;
});
ReportOutputFile.SaveToFile("Sources/ReportOutputFile.xls", ExcelVersion.Version97to2003);