XlsxWriter
public static class XlsxWriter
Namespace SharpCell.Xlsx · package SharpCell.Xlsx
Saves a workbook as an .xlsx file: values, formulas, styles, number formats, sizes, merged cells, panes, sheets, defined names and tables. A workbook read by XlsxReader is saved into the file it was read from: everything SharpCell does not model (charts, pivot tables, comments, conditional formats, macros) is copied unchanged, and so is every cell that did not change. A workbook built in code becomes a new file. Call Workbook.Recalculate before saving.
Methods
Save(Workbook, Stream)
public static void Save(Workbook workbook, Stream stream)
Saves the workbook to a stream, which is left open.
Parameters
workbook: A recalculated workbook, read by XlsxReader or built in code.stream: Where the .xlsx content goes; it need not be seekable. Nothing is written when the save is refused.
Exceptions
NotSupportedException: A cell of an Excel data table changed, or a cell holds#SPILL!or#CALC!as a value.InvalidOperationException: Some formulas are not calculated: call Workbook.Recalculate first; or the workbook has no sheets.XlsxWriteException: SharpCell could not calculate some formulas; see XlsxWriteOptions.KeepUncalculated.
Save(Workbook, Stream, XlsxWriteOptions)
public static void Save(Workbook workbook, Stream stream, XlsxWriteOptions options)
Saves the workbook to a stream, which is left open.
Parameters
workbook: A recalculated workbook, read by XlsxReader or built in code.stream: Where the .xlsx content goes; it need not be seekable. Nothing is written when the save is refused.options: What to do with formulas SharpCell cannot calculate.
Exceptions
NotSupportedException: A cell of an Excel data table changed, or a cell holds#SPILL!or#CALC!as a value.InvalidOperationException: Some formulas are not calculated: call Workbook.Recalculate first; or the workbook has no sheets.XlsxWriteException: SharpCell could not calculate some formulas andoptionsdoes not keep them.
Save(Workbook, string)
public static void Save(Workbook workbook, string path)
Saves the workbook to a file, replacing it if it exists (the file it was read from too).
Parameters
workbook: A recalculated workbook, read by XlsxReader or built in code.path: Path of the .xlsx file to write (.xlsm for a macro-enabled workbook read from one). The file is replaced only once the new one is complete.
Exceptions
NotSupportedException: A cell of an Excel data table changed, or a cell holds#SPILL!or#CALC!as a value.InvalidOperationException: Some formulas are not calculated: call Workbook.Recalculate first; or the workbook has no sheets.XlsxWriteException: SharpCell could not calculate some formulas; see XlsxWriteOptions.KeepUncalculated.
Save(Workbook, string, XlsxWriteOptions)
public static void Save(Workbook workbook, string path, XlsxWriteOptions options)
Saves the workbook to a file, replacing it if it exists (the file it was read from too).
Parameters
workbook: A recalculated workbook, read by XlsxReader or built in code.path: Path of the .xlsx file to write (.xlsm for a macro-enabled workbook read from one). The file is replaced only once the new one is complete.options: What to do with formulas SharpCell cannot calculate.
Exceptions
NotSupportedException: A cell of an Excel data table changed, or a cell holds#SPILL!or#CALC!as a value.InvalidOperationException: Some formulas are not calculated: call Workbook.Recalculate first; or the workbook has no sheets.XlsxWriteException: SharpCell could not calculate some formulas andoptionsdoes not keep them.