using (var xlPackage = new ExcelPackage())
{
// add a sheet
var ws = xlPackage.Workbook.Worksheets.Add("Sheet1");
// add data to sheet
// ws.SetValue(row, col, value);
// ...
// select the range that will be included in the table
var range = ws.Cells[startRow, startColumn, endRow, endColumn];
// add the excel table entity
var table = ws.Tables.Add(range, "table1");
table.ShowTotal = true;
table.TableStyle = TableStyles.Light2;
// add aggregate formulas (get these from an existing table in Excel)
table.Columns[1].TotalsRowFormula = "SUBTOTAL(103,[Column1])"; // count
table.Columns[2].TotalsRowFormula = "SUBTOTAL(109,[Column2])"; // sum
table.Columns[3].TotalsRowFormula = "SUBTOTAL(101,[Column3])"; // average
return xlPackage.GetAsByteArray();
}
EPPLus: Format as Table
Format data just like the "Format as Table" function in Excel.
Labels:
C#,
EPPlus,
Excel 2007,
xlsx
IIS 7: Windows Authentication Not Listed
- Open Server Manager (Right Click Computer, Click Manage)
- Expand Roles, Right Click Web Server, Click Add Role
- Expand Web Server -> Security, Check Windows Authentication
- Click Install
Subscribe to:
Posts (Atom)