When there is an abstractNum defined with the same abstractNumId in word\glossary\numbering.xml and in the word\numbering.xml, a "System.ArgumentException: An item with the same key has already been added." exception is thrown.
In other cases, the import overwrites the styles from the main document part with the ones defined in the glossary or fails to import different parts of the content.
Workaround: Delete the glossary files:
string path = "File.docx";
using (Stream str = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
using (ZipArchive archive = ZipArchive.Update(str, null))
{
foreach (ZipArchiveEntry entry in archive.Entries.ToList())
{
if (entry.FullName.Contains("glossary/"))
{
entry.Delete();
}
}
}
DocxFormatProvider provider = new DocxFormatProvider();
RadFlowDocument flowDocument = provider.Import(str, null);
}
Getting an exception message when trying to view a document as a PDF using the PdfFormatProvider which started happening only after upgrading Telerik to the latest version, 7.1.0 in Telerik UI for Blazor.
Exception Message:
width should be greater or equal than 0. (Parameter 'width')
I have copied the stack trace and source of the exception below:
Source: Telerik.Documents.Fixed
Stack Trace: at Telerik.Windows.Documents.Fixed.Model.Editing.Layout.ContentElementLayoutElementBase`1.DrawHighlights(DrawLayoutElementContext context)
at Telerik.Windows.Documents.Fixed.Model.Editing.Layout.ContentElementLayoutElementBase`1.Draw(DrawLayoutElementContext context)
at Telerik.Windows.Documents.Fixed.Model.Editing.Block.Draw(IEnumerable`1 lineElements, DrawLayoutElementContext context)
at Telerik.Windows.Documents.Fixed.Model.Editing.Block.DrawInternal(FixedContentEditor editor, Rect boundingRect)
at Telerik.Windows.Documents.Fixed.Model.Editing.Block.Telerik.Windows.Documents.Fixed.Model.Editing.Flow.IDrawArrangedElement.DrawArrangedElement(FixedContentEditor editor, Rect boundingRect)
at Telerik.Windows.Documents.Fixed.Model.Editing.Flow.SectionInfo.DrawArrangedElement(IBlockElement blockElement, Double horizontalOffset, Double verticalOffset)
at Telerik.Windows.Documents.Fixed.Model.Editing.Utils.SectionInfoExtensions.DrawArrangedElements(SectionInfo section, IList`1 elements)
at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.Draw()
at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.StartNewPage(SectionProperties sectionProperties)
at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.StartNewPage()
at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.AddBlock(IBlockElement blockElement, CancellationToken cancellationToken)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportSection(Section section, RadFixedDocumentEditor editor)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportDocument(RadFlowDocument document, RadFixedDocumentEditor editor)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportInternal()
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.Export()
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportToFixedDocument(RadFlowDocument document, CancellationToken cancellationToken)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFlowDocument document, Stream output, CancellationToken cancellationToken)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFlowDocument document, Stream output)
at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
at Telerik.Windows.Documents.Common.FormatProviders.BinaryFormatProviderBase`1.Export(T document)
An error occurs while importing an XLSX document with charts. Here is the stack trace:
at Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.Contexts.XlsxWorkbookImportContext.PairSeriesGroupsWithAxes() at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.Chart.PlotAreaElement.CopyPropertiesTo(IOpenXmlImportContext context, DocumentChart chart) at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.Chart.ChartElement.CopyPropertiesTo(IOpenXmlImportContext context, DocumentChart chart) at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.Chart.ChartSpaceElement.OnAfterRead(IOpenXmlImportContext context) at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(IOpenXmlReader reader, IOpenXmlImportContext context) at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Parts.ChartPart.Import(IOpenXmlReader reader, IOpenXmlImportContext context) at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Parts.OpenXmlPartBase.Import(Stream stream, IOpenXmlImportContext context) at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.ImportPartFromArchive(ZipArchiveEntry zipEntry, PartBase part, IOpenXmlImportContext context) at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.Import(Stream input, IOpenXmlImportContext context) at Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider.ImportOverride(Stream input, CancellationToken cancellationToken) at Telerik.Windows.Documents.Spreadsheet.FormatProviders.WorkbookFormatProviderBase.Import(Stream input, Nullable`1 timeout)
Add support for pivot tables.
Currently, RadSpreadProcessing supports the following options:
namespace Telerik.Windows.Documents.Model.Drawing.Charts
{
/// <summary>
/// Specifies where a chart legend is placed relative to the plot area.
/// </summary>
public enum LegendPosition
{
/// <summary>
/// Positions the legend to the right of the plot area.
/// </summary>
Right,
/// <summary>
/// Positions the legend below the plot area.
/// </summary>
Bottom,
/// <summary>
/// Positions the legend to the left of the plot area.
/// </summary>
Left,
/// <summary>
/// Positions the legend above the plot area.
/// </summary>
Top
}
}MS Excel supports setting "Top Right" Legend Position:
Currently, if you have a decimal column in the DataTable, it is imported as a text column in the workbook. It should be preserved as a numeric column after importing.
Note: When importing a DataTable, each of the column's type is checked and a respective cell type is imported.
if (dataType.IsValueType && dataType.IsPrimitive && !dataType.IsEnum)
{
newValue = new NumberCellValue(Convert.ToDouble(value));
}The check ensures only “simple” CLR value types are treated as numbers when importing from DataTable to the worksheet.This is the code for import/export which result is illustrated below:
string inputFilePath = "test1.doc";
Telerik.Windows.Documents.Flow.Model.RadFlowDocument document;
Telerik.Windows.Documents.Flow.FormatProviders.Doc.DocFormatProvider doc_provider = new Telerik.Windows.Documents.Flow.FormatProviders.Doc.DocFormatProvider();
using (Stream input = File.OpenRead(inputFilePath))
{
document = doc_provider.Import(input, TimeSpan.FromSeconds(10));
}
Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider docx_provider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
string outputFilePath = "Exported.docx";
using (Stream output = File.OpenWrite(outputFilePath))
{
docx_provider.Export(document, output, TimeSpan.FromSeconds(10));
}
Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });This is the code for reproducing the incorrect PDF document. If the step with changing the font is commented, the document is exported properly:
//Step 1: Create an instance of XlsxFormatProvider to import the Excel file
XlsxFormatProvider xlsxFormatProvider = new XlsxFormatProvider();
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider pdfFormatProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
Workbook workbook;
using (FileStream input = new FileStream("Input.xlsx", FileMode.Open))
{
workbook = xlsxFormatProvider.Import(input, TimeSpan.FromSeconds(10));
}
//Step 2: Export the workbook to PDF RadFixedDocument to modify fonts
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider spread_pdf_provider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
RadFixedDocument fixedDocument = spread_pdf_provider.ExportToFixedDocument(workbook, TimeSpan.FromSeconds(10));
foreach (var page in fixedDocument.Pages)
{
foreach (var content in page.Content)
{
if (content is TextFragment text)
{
// Replace the font with Helvetica or HelveticaBold based on the original font style
text.Font = text.Font.Name.ToLower().Contains("bold")
? FontsRepository.HelveticaBold
: FontsRepository.Helvetica;
}
}
}
//Step 3: Save the modified RadFixedDocument back to PDF
string outputFileName = "ExportedWorkbook.pdf";
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider fixed_pdf_provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
using (FileStream output = new FileStream(outputFileName, FileMode.Create))
{
fixed_pdf_provider.ExportSettings.DocumentUnhandledException += ExportSettings_DocumentUnhandledException;
fixed_pdf_provider.ExportSettings.FontEmbeddingType = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.FontEmbeddingType.Subset;
fixed_pdf_provider.Export(fixedDocument, output, TimeSpan.FromSeconds(10));
}
Process.Start(new ProcessStartInfo() { FileName = outputFileName, UseShellExecute = true });
When importing a large document (e.g. 2.3GB) , the library fails to parse int value that exceeds the limit which leads to endless importing:
LocalizableException is thrown after removing columns from a workbook with set Print Titles.
Workaround - Remove the PrintTitles before removing the columns:
WorksheetPageSetup pageSetup = workbook.ActiveWorksheet.WorksheetPageSetup;
pageSetup.PrintTitles.RepeatedRows = null;
pageSetup.PrintTitles.RepeatedColumns = null;
HtmlFormatProvider: Styles are not correctly preserved when a <b> tag is applied to the same styled element.
Workaround: Apply bold through CSS instead of using <b>.