...
Example
Here is an example ASP.NET Page class that demonstrates how to use Formulas with ExcelApplication:
Code Block | ||||
---|---|---|---|---|
| ||||
using SoftArtisans.OfficeWriter.ExcelWriter; public class FormulaDemo : System.Web.UI.Page { protected void Page_Load(object sender, System.EventArgs e) { //--- Create ExcelApplication, a Workbook, and a Worksheet ExcelApplication xlw = new ExcelApplication(ExcelApplication.FileFormat.Xlsx); Workbook wb = xlw.Create(); Worksheet sheet1 = wb.Worksheets[0]; //--- Write some values into cells for the //--- formulas to compute sheet1.Cells["A1"].Value = 1; sheet1.Cells["A2"].Value = 2; sheet1.Cells["A3"].Value = 3; //--- Write a formula into a cell //--- Formula will be calculated //--- when opened in Excel sheet1.Cells["A4"].Formula = "=SUM(A1:A3)"; //--- Save the workbook xlw.Save(wb, Page.Response, "Generated.xlsxlsx", false); } } |
Code Sample: ExcelApplication Basic Steps
This sample shows many of the core features of ExcelApplication, including the use of formulas.