Message-ID: <1275579462.8135.1711633775594.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8134_304687130.1711633775594" ------=_Part_8134_304687130.1711633775594 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
To insert a formula in a cell, use the propertyCell.Formula. Begin the f= ormula string with =3D, as you would when entering a formula in Microsoft E= xcel:
sheet1.Cells["A25"].Formula =3D "=3DSUM(A4:A24)&q= uot;;=20
ExcelWriter allows you to use values from a different sheet when assigni= ng a formula to a cell, as in the following examples:
sheet1.Cells[5,3].Formula =3D "=3DSUM(Sheet1!A1:A3,Sheet3!A= 1:A5)";=20
The property Cell.Name returns a cell's Excel-style name (e.g., "B5= "). This property can be useful if you want to build a formula string = using row and column indexes, rather than cell names, for example:
String formula =3D "=3DSUM(" + sheet1.Cells[3, 1].Name= + ":" + sheet1.Cells[23, 1].Name + ")"; sheet1.Cells[24, 1].Formula =3D formula;=20
Here is an example that demonstrates how to use Formulas with ExcelAppli= cation:
//--- Create ExcelApplication, a Workbook, and a Worksheet ExcelApplication xlw =3D new ExcelApplication(); Workbook wb =3D xlw.Create(ExcelApplication.FileFormat.Xlsx); Worksheet sheet1 =3D wb.Worksheets[0]; //--- Write some values into cells for the //--- formulas to compute sheet1.Cells["A1"].Value =3D 1; sheet1.Cells["A2"].Value =3D 2; sheet1.Cells["A3"].Value =3D 3; //--- Write a formula into a cell //--- Formula will be calculated //--- when opened in Excel sheet1.Cells["A4"].Formula =3D "=3DSUM(A1:A3)"; //--- Save the workbook xlw.Save(wb, "Generated.xlsx");=20
This sample shows many of the core features of ExcelApplication, includi= ng the use of formulas.