Exporting sheet properties corrupts the file and it cannot be opened in Excel.
In the latest version we export:
<sheetPr>
<pageSetUpPr fitToPage="true" />
<tabColor rgb="FF92D050" />
</sheetPr>
Excel cannot read this and tries to recover the file unsuccessfully. This works in R3 2020.
Hello,
An exception is thrown when importing an xlsx file which has a comment that does not have an author. But the author may be null.
System.ArgumentException: 'author' This exception was originally thrown at this call stack: Telerik.Windows.Documents.Spreadsheet.Utilities.Guard.ThrowExceptionIfNullOrEmpty(string, string) Telerik.Windows.Documents.Spreadsheet.Model.NoteCollection.Add(Telerik.Windows.Documents.Spreadsheet.Model.CellIndex, Telerik.Windows.Documents.Spreadsheet.Model.CellIndex, string, string) Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Contexts.XlsxWorksheetImportContext.ApplyNoteInfo(Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Contexts.NoteBase) Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Model.Elements.Comments.CommentElement.OnAfterRead(Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Import.IXlsxWorksheetImportContext) Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Model.Elements.Comments.CommentsElementBase.OnAfterRead(Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Import.IXlsxWorkbookImportContext) Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase<TImportContext, TExportContext, TPartsManager>.OnAfterRead(Telerik.Windows.Documents.FormatProviders.OpenXml.Import.IOpenXmlImportContext) Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(Telerik.Windows.Documents.FormatProviders.OpenXml.IOpenXmlReader, Telerik.Windows.Documents.FormatProviders.OpenXml.Import.IOpenXmlImportContext) Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.ReadChildElements(Telerik.Windows.Documents.FormatProviders.OpenXml.IOpenXmlReader, Telerik.Windows.Documents.FormatProviders.OpenXml.Import.IOpenXmlImportContext) Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(Telerik.Windows.Documents.FormatProviders.OpenXml.IOpenXmlReader, Telerik.Windows.Documents.FormatProviders.OpenXml.Import.IOpenXmlImportContext) Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.ReadChildElements(Telerik.Windows.Documents.FormatProviders.OpenXml.IOpenXmlReader, Telerik.Windows.Documents.FormatProviders.OpenXml.Import.IOpenXmlImportContext) ... [Call Stack Truncated]
This is the code that can be used to reproduce the issue, according to your documentation:
Workbook workbook;
XlsxFormatProvider formatProvider = new XlsxFormatProvider();
using (Stream input = new FileStream(_path, FileMode.Open))
{
workbook = formatProvider.Import(input);
}
I have attached a document that got a comment without an author.
The values applied to the row/column should be explicitly set on each used cell as well. Otherwise, if they are applied on row/column only, the used cells don't use the desired values when opening the document.
To reproduce:
Observed: All cells except A1 have the specified color.
Workaround: Use cell selection, e.g.:
sheet.Cells[0,10].SetFill(PatternFill.CreateSolidFill(Colors.Red));
For example:
Renaming a sheet named "Sheet1" to "Sheet 1", should update formulas references to it to 'Sheet 1!' (notice single quotes), which it does not. The formula =SUM(Sheet1!A2:C2) changes to the invalid expression =SUM(Sheet 1!A2:C2). This breaks formulas referencing that sheet.
Workaround:
Iterate all cells with formulas in the workbook and add single quotes to the beginning and end of sheet name reference. The attached project changes the name of Sheet1 and then fixes all formula references to it by enclosing its name in single quotes.