Getting empty worksheets in workbook created from datatables.
See original GitHub issueRead and complete the full issue template
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
- Bug
- Feature
- Question
Did you test against the latest CI build?
- Yes
- No
If you answered No
, please test with the latest development build first.
Version of ClosedXML 0.95.3
What is the current behavior? workbook is created with worksheets using fully populated datatables. Worksheets are created with the correct number of columns and rows, but no data from the datatables is being populated into the worksheet cells. Columns are only labled as Column1, Column2, Column3 etc… Worksheets do have the correct names from the datatable names. While debugging I an view the datatable data from the Visual Studio visualizer. The table data looks well-formed. (https://github.com/ClosedXML/ClosedXML/files/5063907/Daily_Reports_12-08-2020_09-32.xlsx)
What is the expected behavior or new feature? data from data tables to be populated in the worksheets of workbook.
Is this a regression from the previous version?
Regressions get higher priority. Test against the latest build of the previous minor version. For example, if you experience a problem on v0.95.3, check whether it the problem occurred in v0.94.2 too.
Problem also occurs in v0.95.2.
Reproducibility
This is an important section. Read it carefully. Failure to do so will cause a ‘RTFM’ comment.
Without a code sample, it is unlikely that your issue will get attention. Don’t be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be minimal complete and verifiable. Sample spreadsheets should be attached whenever applicable. Remove sensitive information.
Unfortunately I am not able to include actual data from the datatable…
public void Main()
{
public XLWorkbook ExportExcelFiles(string checkedReportsString)
{
using (var wb = new XLWorkbook())
{
//find each report id in the url parameter sting and create and excel workbook with a worksheet for each one
string reportId = null;
foreach (char c in checkedReportsString)
{
//find the next report id in url parameter string and create an excel worksheet from it
if (c != char.Parse("~"))
{
reportId = reportId + c;
continue;
}
else if (c == char.Parse("~"))
{
//create datatable of the current report
string reportName = GetReportTableName(reportId);
DataTable reportDataTable = GetTableData(reportId, reportName);
//add datatable to workbook
if (reportDataTable != null && reportDataTable.Rows.Count > 0)
{
reportDataTable.TableName = $"{GetReportTableName(reportId).Substring(7)}_{GetReportDateStringWithTime(reportId)}";
var ws = wb.Worksheets.Add(reportDataTable);
}
reportId = null;
}
}
if (wb != null) return wb;
else throw new Exception("No Data to Report");
}
}
}
- [x ] I attached a sample spreadsheet. (You can drag files on to this issue)
[Daily_Reports_12-08-2020_09-32.xlsx] testWorkbook.xlsx
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (10 by maintainers)
Top GitHub Comments
Sure thing.
On Tue, Aug 18, 2020, 6:38 PM Francois Botha notifications@github.com wrote:
Fixed in #1499