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
Using the ExcelApplication object's Save methods, you can:
To save the generated file on the server, call one of the following meth= ods:
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.
ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(); xla.Save(wb, @"C:\Sales2003\June.xlsx");=20
To stream the generated file to the client, call one of the following me= thods:
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.
ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(ExcelApplication.FileFormat.Xlsx); xla.Save(wb, Page.Response, "workbook.xlsx", false);=20
To write the generated spreadsheet to a System.IO.Stream, call the follo= wing method:
void Save(Workbook workbook, System.IO.Stream stream)=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
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:
void ExcelTemplate.Open(ExcelApplication excelApplication, Workb= ook workbook)=20
ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(ExcelApplication.FileFormat.Xlsx); ExcelTemplate xlt =3D new ExcelTemplate(); xlt.Open(xla, wb)=20