// 4. Add sample data (normally from DB) worksheet.Cells["A2"].Value = "Widget A"; worksheet.Cells["B2"].Value = 150; worksheet.Cells["C2"].Value = 12.99;
// 1. Create a new workbook and get the active worksheet IWorkbook workbook = Factory.GetWorkbook(); IWorksheet worksheet = workbook.Worksheets["Sheet1"]; worksheet.Name = "Sales Report";
// 2. Define headers worksheet.Cells["A1"].Value = "Product"; worksheet.Cells["B1"].Value = "Units Sold"; worksheet.Cells["C1"].Value = "Unit Price"; worksheet.Cells["D1"].Value = "Total Revenue"; spreadsheetgear example
// 5. Write Excel formulas for total revenue worksheet.Cells["D2"].Formula = "=B2*C2"; worksheet.Cells["D3"].Formula = "=B3*C3";
// 7. Format currency column worksheet.Cells["C2:C3"].NumberFormat = "$#,##0.00"; worksheet.Cells["D2:D5"].NumberFormat = "$#,##0.00"; Define headers worksheet
// 3. Apply formatting to headers (bold, background color) IRange headerRange = worksheet.Cells["A1:D1"]; headerRange.Font.Bold = true; headerRange.Interior.Color = System.Drawing.Color.LightGray; headerRange.Borders.LineStyle = SpreadsheetGear.Advanced.Cells.LineStyle.Continuous;
// 8. Auto-fit columns for readability worksheet.Cells["A:D"].Columns.AutoFit(); Apply formatting to headers (bold, background color) IRange
// 6. Add totals row worksheet.Cells["A5"].Value = "TOTALS"; worksheet.Cells["B5"].Formula = "=SUM(B2:B3)"; worksheet.Cells["D5"].Formula = "=SUM(D2:D3)";
worksheet.Cells["A3"].Value = "Widget B"; worksheet.Cells["B3"].Value = 75; worksheet.Cells["C3"].Value = 24.50;