...
- Create an instance of ExcelApplication:
Code Block c# c# ExcelApplication xla = new ExcelApplication();
- Open an Excel workbook from a file path or a System.IO.Stream:
Or:Code Block c# c# //--- Open a workbook from a file path: Workbook wb = xla.Open(@"C:\Reports\Report.xlsx");
Code Block c# c# //--- Open a workbook from a Stream: FileStream fs = new FileStream(@"C:\Sales\2003\June.xlsx", FileMode.Open); Workbook wb = xla.Open(fs);
- Return a Worksheet object:
Code Block c# c# Worksheet ws = wb.Worksheet[0];
- Modify the worksheet. For example, add a cell value:
Code Block c# c# ws.Cells[0, 0].Value = "Welcome to SoftArtisans OfficeWriter";
- Save the modified file with a new name, or stream it to the client:
Or:Code Block c# c# //--- Save the file on the server: xla.Save(wb, @"C:\temp\out.xlsx");
For more information on save options, see Output Options.Code Block c# c# //--- Stream the file to the client via HTTP: //--- false means Open In Excel, true means Open In Browser (IE only) xla.Save(wb, Page.Response, "out.xlsx", false);
\