EPPlus - Filters automatically added for empty cells in additional worksheets

399 Views Asked by At

I am using EPPlus to export dataset into Excel. There is no issues when i have 1 worksheet in a workbook. When i add additional worksheets, the worksheets empty cells added with filters automatically like below. Any solution to avoid such unwanted filters?

excel automatically added filters

using (var package = new ExcelPackage(newFile))
{
DataTable sourceTable = dsSource.Tables[0];            
TableStyles tableStyles1 = OfficeOpenXml.Table.TableStyles.Custom;
ExcelWorksheet worksheet1 = package.Workbook.Worksheets.Add(sheetName + 
"1");

ExcelRangeBase range1 = worksheet1.Cells[1,1, sourceTable.Rows.Count - 1, 
sourceTable.Columns.Count - 1].LoadFromDataTable(sourceTable, true, 
tableStyles1);

sourceTable = dsSource.Tables[1];
TableStyles tableStyles2 = OfficeOpenXml.Table.TableStyles.Custom;
ExcelWorksheet worksheet2 = package.Workbook.Worksheets.Add(sheetName + 
"2");    
ExcelRangeBase range2 = worksheet2.Cells[1, 1, sourceTable.Rows.Count - 1, 
sourceTable.Columns.Count - 1].LoadFromDataTable(sourceTable, true, 
tableStyles2);    
package.Save();
}
0

There are 0 best solutions below