/// <summary> /// Save a workbook to a MemoryStream /// </summary> /// <exception cref="InvalidOperationException">Thrown if there are no <see cref="Worksheet">sheets</see> in the workbook.</exception> /// <returns></returns> internal static void Save(Workbook workbook, CompressionLevel compressionLevel, Stream outputStream) { if (workbook.SheetCount == 0) { throw new InvalidOperationException("You are trying to save a Workbook that does not contain any Worksheets."); } CompressionOption option; switch (compressionLevel) { case CompressionLevel.Balanced: option = CompressionOption.Normal; break; case CompressionLevel.Maximum: option = CompressionOption.Maximum; break; case CompressionLevel.NoCompression: default: option = CompressionOption.NotCompressed; break; } var writer = new XlsxWriterInternal(workbook, option); writer.Save(outputStream); }
/// <summary> /// Save a workbook to a MemoryStream /// </summary> /// <exception cref="InvalidOperationException">Thrown if there are no <see cref="Worksheet">sheets</see> in the workbook.</exception> /// <returns></returns> internal static void Save(Workbook workbook, Stream outputStream, bool compress) { if (workbook.SheetCount == 0) { throw new InvalidOperationException("You are trying to save a Workbook that does not contain any Worksheets."); } XlsxWriterInternal.Save(workbook, outputStream, compress); }