Message-ID: <1652537709.9385.1711689876735.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9384_2104139094.1711689876735" ------=_Part_9384_2104139094.1711689876735 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Output Options for ExcelApplication

Output Options for ExcelApplication

The ExcelApplication object has several options for saving your Exc= elApplication generated file.

Using the ExcelApplication object's Save methods, you can:

=20 =20

=20
=20 Icon=20
=20

When ExcelWriter streams a file to the client, the output result will de= pend on the browser as well as the server-side script.

=20
=20
=20

Save to Disk

To save the generated file on the server, call one of the following meth= ods:

=20
void Save(Workbook workbook, string fileName)
void Save(Workbook workbook, string fileName)
=20

fileName specifies a complete physical path and file name for the genera= ted file. ExcelWriter will save the file to this location. If a file with t= he same name exists, it will be overwritten by the new Excel file.

Example

=20
ExcelApplication xla =3D new ExcelApplication();
Workbook wb =3D xla.Create();
xla.Save(wb, @"C:\Sales2003\June.xlsx");
=20

Stream to Client=

To stream the generated file to the client, call one of the following me= thods:

=20
void Save(Workbook workbook, System.Web.HttpResponse response, s=
tring fileName)
void Save(Workbook workbook, System.IO.Stream stream)
void Save(Workbook workbook, System.Web.HttpResponse response, string fileN=
ame, bool openInBrowser)
void Save(Workbook workbook, System.Web.HttpResponse response, string fileN=
ame, bool openInBrowser, string contentType)
=20

Browsers other than Internet Explorer cannot embed an Excel file in the = browser window. When the generated spreadsheet is streamed to a browser oth= er than IE, the user will always be prompted to open or save the file. If t= he user chooses to open the file, it will open in Microsoft Excel or anothe= r spreadsheet application.

Internet Explorer can display an Excel file in the browser window. When = the generated spreadsheet is streamed to Internet Explorer, the browser's s= ettings will determine whether the file opens automatically or the user is = asked to open or save the file. The parameter openInBrowserdetermines wheth= er the file will open in IE or in a spreadsheet application. If openInBrows= er is set to true, the response content-disposition header is set to open t= he file in the browser window.

Example

=20
 ExcelApplication xla =3D new ExcelApplication();
Workbook wb =3D xla.Create(ExcelApplication.FileFormat.Xlsx);
xla.Save(wb, Page.Response, "workbook.xlsx", false);
=20

Write to Stream

To write the generated spreadsheet to a System.IO.Stream, call the follo= wing method:

=20
void Save(Workbook workbook, System.IO.Stream stream)
=20

Example

=20
 ExcelApplication xla =3D new ExcelApplication();
Workbook wb =3D xla.Create(ExcelApplication.FileFormat.Xlsx);
FileStream fstream =3D new FileStream(@"C:\temp\outfile.xlsx",
FileMode.Create);
xla.Save(wb, fstream);
=20

Return a Templa= te

You can use ExcelApplication to create a spreadsheet with data markers (= i.e., a template) and pass the spreadsheet to ExcelTemplate to populate the= data markers. In this case, do not call Save. Instead, pass your Workbook = object to ExcelTemplate's Open method:

=20
void ExcelTemplate.Open(ExcelApplication excelApplication, Workb=
ook workbook)
=20

Example

=20
 ExcelApplication xla =3D new ExcelApplication();
Workbook wb =3D xla.Create(ExcelApplication.FileFormat.Xlsx);
ExcelTemplate xlt =3D new ExcelTemplate();
xlt.Open(xla, wb)
=20

 

 

------=_Part_9384_2104139094.1711689876735--