Message-ID: <196193730.7819.1711622663827.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7818_554802772.1711622663827" ------=_Part_7818_554802772.1711622663827 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Formulas

Formulas

ExcelApplication supports all math, string, boolean, time, statisti= cal, database, lookup and reference formulas or functions that are part of = Excel. ExcelWriter does not calculate formulas at run-time; all formulas ar= e calculated when the workbook is opened in Excel.

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:

=20
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:

=20
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:

=20
String formula =3D "=3DSUM(" + sheet1.Cells[3, 1].Name=
 +
     ":" + sheet1.Cells[23, 1].Name + ")";
sheet1.Cells[24, 1].Formula =3D formula;
=20

Example

Here is an example that demonstrates how to use Formulas with ExcelAppli= cation:

=20
//--- 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

Code Sample

This sample shows many of the core features of ExcelApplication, includi= ng the use of formulas.

[C#] | [VB.NET]

------=_Part_7818_554802772.1711622663827--