...
outputFileName specifies a complete path and file name for the generated file. ExcelWriter will save the file to this location. If a file with the same name exists, it will be overwritten by the new Excel file.
Example
Code Block | c# | c# |
---|---|
title | C# |
Csharp | |
excelTmpl.Save(@"C:\Reports\Orders.xls"); | |
Code Block | vb.net | vb.net |
title | VB.NET |
Vbnet |
---|
excelTmpl.Save("c:\Reports\Orders.xls") |
Anchor | ||||
---|---|---|---|---|
|
Save(outputStream)
...
If you pass Save a System.IO.FileStream, ExcelWriter will save the generated file on the server. If you pass Save Response.OutputStream, ExcelWriter will stream the the generated file to the client.
Example
Code Block | c# | c# |
---|---|
title | C# |
Csharp | |
//-- FileStream and FileMode are in the System.IO namespace FileStream fstream = new FileStream(@"C:\temp\outfile.xls", FileMode.Create); //-- Pass the FileStream to ExcelTemplate excelTmpl.Save(fstream); //-- Close the FileStream (could be in a finally block) fstream.Close(); | |
Code Block |
vb.net | vb.net |
title | VB.NET |
---|---|
Vbnet | |
'-- FileStream and FileMode are in the System.IO namespace
fstream As New FileStream("C:\temp\outfile.xls", FileMode.Create) '-- Pass the FileStream to ExcelTemplate
'-- Close the FileStream (could be in a finally block)
|
Anchor | ||||
---|---|---|---|---|
|
Save(response)
...
If you pass Save an HttpResponse object, ExcelWriter will stream the generated file to the client. If the user chooses to open (rather than save) the file, it will open in the browser window. The browser will use the ExcelWriter script name as the default file name displayed in the File Download dialog. To set a different file name and/or to open the file in Microsoft Excel, use the signature Save(response, attachmentName, OpenInBrowser).
Example
Code Block | c# | c# |
---|---|
title | C# |
Csharp | |
excelTmpl.Save(Page.Response); | |
Code Block |
vb.net | vb.net |
title | VB.NET |
---|---|
Vbnet | |
excelTmpl.Save(Page.Response) |
Anchor | ||||
---|---|---|---|---|
|
Save(response, attachmentName, OpenInBrowser)
...
The parameter attachmentName specifies a name for the generated Excel file; this name will be displayed in the download dialog when the file is streamed to the browser. If the parameter openInBrowser is set to true, and the user chooses to open the file, the file will open in the browser window. If openInBrowser is set to false, and the user chooses to open the file, the file will open in Microsoft Excel. By default, the file will open in the browser window. Note: not all browsers can embed an Excel file in the browser window.
Code Block | c# | c# |
---|---|
title | C# |
Csharp | |
excelTmpl.Save(Page.Response, "Output.xls", false); | |
Code Block | vb.net | vb.net |
title | VB.NET |
Vbnet |
---|
excelTmpl.Save(Page.Response, "Output.xls", False) |
Anchor | ||||
---|---|---|---|---|
|
Pass the Template to ExcelApplication
...