Telerik Forums
Telerik Document Processing Forum
1 answer
505 views
I'm working on a program that creates DOCX file from JSON data using Telerik word processing library. This file uses RTL language scripts.The problem is there is no way to set font style for complex script (not Latin) in styles. for example I set the font size to 11 but when I set the Run's FlowDirection to RightToLeft, the library ignores the font size and uses the default size (the size  for Latin script).  How can I set font size for complex scripts (like Arabic or Persian) ?
Tanya
Telerik team
 answered on 01 Aug 2018
1 answer
367 views

Hi, I'm using the Spread Stream Processing to generate an excel file with 93 columns. All the columns are formatted as strings with an average size of approximately 10-20 characters. I implemented this feature because I need to create excel files of approximately 60k - 80k rows. Currently, I receive an exception when exporting data with 695 rows or more. 

This is the exception I receive: 

Data: System.Collections.ListDictionaryInternal
Message: The Writer is closed or in error state.
Source: System.Xml 
Stack Trace: at System.Xml.XmlWellFormedWriter.AdvanceState(Token token) at System.Xml.XmlWellFormedWriter.WriteEndElement() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutiveElementBase.EndWriteElement() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutiveElementBase.EnsureWritingEnded() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutiveElementBase.EnsureWritingEnded() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutivePartWriterBase`1.EndWrite() at Telerik.Documents.SpreadsheetStreaming.ImportExport.Core.ConsecutivePartWriterBase`1.CompleteWriteOverride() at Telerik.Documents.SpreadsheetStreaming.Core.EntityBase.Dispose(Boolean disposing) at Telerik.Documents.SpreadsheetStreaming.XlsxWorksheetExporter.DisposeOverride() at Telerik.Documents.SpreadsheetStreaming.Core.EntityBase.Dispose(Boolean disposing) at Telerik.Documents.SpreadsheetStreaming.Core.EntityBase.Dispose() at ERMgtProgram.Controllers.DigitalMerchandising.ViewAllExportController.<GenerateDocument>d__4.MoveNext() in C:\Users\erit12u\source\repos\ERMgtProgram\ERMgtProgram\Controllers\DigitalMerchandising\Import\ViewAllExportController.cs:line 107
Target Site: Void AdvanceState(Token)

 

This is the code that generates the exception: 

01.// When this code is called for the 695th time it throws an exception at line 2
02.using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
03.{
04.    rowExporter.SetHeightInPoints(rowHeight);
05. 
06.    foreach(var column in template)
07.    {
08.        using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
09.        {
10.            var val = entities[rowIndex].Properties.Keys.Contains(column.FinalColumnName) ? entities[rowIndex].Properties[column.FinalColumnName].StringValue : string.Empty;
11.            cellExporter.SetValue(val);
12.            cellExporter.SetFormat(normalFormat);
13.        }
14.    }
15.}

 

 

This is all of my relevant source code: 

001.[HttpPost]
002.public async Task<ActionResult> GenerateDocument()
003.{
004.    byte[] renderedBytes = null;
005.    var mimeType = "application / vnd.openxmlformats - officedocument.spreadsheetml.sheet"; ;
006.    var fileExtension = "xlsx";
007.    try
008.    {
009.        // retrieve database data
010.        var tableName = _dmP3AzTableName;
011.        // retrieve all entities in azure table
012.        CloudStorageAccount storageAccount = _storageConn.GetStorageConnection();
013.        CloudTable table = storageAccount.CreateCloudTableClient().GetTableReference(tableName);
014.        table.CreateIfNotExists();
015.        var entities = await AzureOperation.RetrieveEntitiesAsync(table, null, 1000);
016.        if (entities == null)
017.        {
018.            TempData["ErrorMessage"] = "Unable to retrieve records. Please try again later.";
019.            return RedirectToAction("Index", "ImportPhaseThree");
020.        }
021.        var template = new List<TemplateSupport>();
022.        using (var db = new DataMgtEntities())
023.        {
024.            template = db.TemplateSupports.OrderBy(p => p.PageOrder).ToList();
025.        }
026.        var headerRowHeight = 15;
027.        var columnHeaders = template.Select(p => p.ImportColumnName).ToArray();
028.        var columnWidthsList = new List<double>();
029.        foreach (var header in columnHeaders)
030.        {
031.            columnWidthsList.Add(25.0);
032.        }
033.        var columnWidths = columnWidthsList.ToArray();
034.        var rowHeight = 15;
035.        MemoryStream documentStream = new MemoryStream();
036.        //documentStream.SetLength(int.MaxValue/10);
037.        var selectedDocumentFormat = SpreadDocumentFormat.Xlsx;
038. 
039.        using (IWorkbookExporter workbookExporter = SpreadExporter.CreateWorkbookExporter(selectedDocumentFormat, documentStream))
040.        {
041.            using (IWorksheetExporter worksheetExporter = workbookExporter.CreateWorksheetExporter("Phase 3 All Records"))
042.            {
043.                for (int i = 0; i < columnWidths.Length; i++)
044.                {
045.                    using (IColumnExporter columnExporter = worksheetExporter.CreateColumnExporter())
046.                    {
047.                        columnExporter.SetWidthInCharacters(columnWidths[i]);
048.                    }
049.                }
050. 
051.                ExportHeaderRows(worksheetExporter, headerRowHeight, columnHeaders);
052.                SpreadCellFormat normalFormat = new SpreadCellFormat
053.                {
054.                    FontSize = 11,
055.                    VerticalAlignment = SpreadVerticalAlignment.Bottom,
056.                    HorizontalAlignment = SpreadHorizontalAlignment.Left
057.                };
058. 
059.                for (var rowIndex = 0; rowIndex < entities.Count(); rowIndex++)
060.                {
061.                    using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
062.                    {
063.                        rowExporter.SetHeightInPoints(rowHeight);
064. 
065.                        foreach(var column in template)
066.                        {
067.                            using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
068.                            {
069.                                var val = entities[rowIndex].Properties.Keys.Contains(column.FinalColumnName) ?
070.                                    entities[rowIndex].Properties[column.FinalColumnName].StringValue : string.Empty;
071.                                cellExporter.SetValue(val);
072.                                cellExporter.SetFormat(normalFormat);
073.                            }
074.                        }
075.                    }
076.                }
077.            }
078.        }
079.        renderedBytes = documentStream.ToArray();
080.    }
081.    catch (Exception ex)
082.    {
083.        TempData["ErrorMessage"] = "An exception occurred. Please see error log for details, and try again later.";
084.        ErrLog.LogError(ex, "ViewAllExport.GenerateDocument");
085.        return RedirectToAction("ViewAll", "ImportPhaseThreeExports");
086.    }
087.    return File(renderedBytes, mimeType, "Phase3AllData." + fileExtension);
088.}
089. 
090.private void ExportHeaderRows(IWorksheetExporter worksheetExporter, int HeaderRowHeight, string[] ColumnHeaders)
091.{
092.    try
093.    {
094.        using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
095.        {
096.            rowExporter.SetHeightInPoints(HeaderRowHeight);
097. 
098.            SpreadCellFormat format = new SpreadCellFormat
099.            {
100.                FontSize = 11,
101.                Fill = SpreadPatternFill.CreateSolidFill(new SpreadColor(122, 122, 122)),
102.                ForeColor = new SpreadThemableColor(new SpreadColor(255, 255, 255)),
103.                HorizontalAlignment = SpreadHorizontalAlignment.Left,
104.                VerticalAlignment = SpreadVerticalAlignment.Bottom
105.            };
106. 
107.            for (int i = 0; i < ColumnHeaders.Length; i++)
108.            {
109.                using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
110.                {
111.                    cellExporter.SetFormat(format);
112.                    cellExporter.SetValue(ColumnHeaders[i]);
113.                }
114.            }
115.        }
116.    }
117.    catch(Exception ex)
118.    {
119.        ErrLog.LogError(ex, "ViewAllExport.ExportHeaderRows");
120.    }
121.}

 

Any and all help is appreciated. This is a time sensitive concern as I have to find a solution for this issue ASAP. Thank you for your time.

Best,

Ruben

Tanya
Telerik team
 answered on 31 Jul 2018
5 answers
296 views

I have A  xlsx file as  Data Template。

for     

Peshito
Telerik team
 answered on 25 Jul 2018
2 answers
126 views

I have a use case to create the excel file using RadSpreadStreamProcessing and then upload it to the blob in cloud. Could you please share me an example if we are able to do so?

Please note this is possible using RadSpreadProcessing but would like to check with RadSpreadStreamProcessing(because it is relatively fast)

Pushpdeep
Top achievements
Rank 1
 answered on 18 Jul 2018
13 answers
894 views

Hi,

I am trying to use pdfprocession to find a certain text string on the first page

Is there a way to walk through the Page?

 

Dim P As RadFixedPage = Doc.Pages.Item(0)

P. ???

Anna
Telerik team
 answered on 13 Jul 2018
1 answer
113 views

I have a list of RadFlowDocuments, and i need to copy all the document to one TableCell, i have tried merging the 2 RadFlowDocuments but the content adds outside the table.

 

How can I achive it?

 

Thank you!

Tanya
Telerik team
 answered on 12 Jul 2018
2 answers
212 views

Hello,

I use Spreadsheet Streaming to Export large Kendo MVC Grid Data - it works great except the Format of the CSV - how to Change the Delimiter, Quote or Encoding of the CSV Export?

robert

Lairger
Top achievements
Rank 1
 answered on 09 Jul 2018
1 answer
476 views

We're converting a DocX file stream to a PDF file stream but we're getting some weird results with the padding on many elements. In a clean, new document, the Margins are always 2.54cm and the individual padding of tables is completely lost. If we try to edit the Margins (even if we change to a new value and back again), the Margins then drop to 0cm from then on and the table padding is still not applied. The conversion code can be found below:

var providerDocx = new DocxFormatProvider();
            var document = providerDocx.Import(response.Data.Document);
            var providerPdf = new PdfFormatProvider
            {
                ExportSettings = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExportSettings
                {
                    ComplianceLevel = PdfComplianceLevel.PdfA2B,
                    ImageQuality = ImageQuality.High
                }
            };
            var outStream = new MemoryStream();
            providerPdf.Export(document, outStream);

Any help or insight you could provide would be appreciated.

Thanks

Peshito
Telerik team
 answered on 06 Jul 2018
3 answers
1.1K+ views

I'm trying to create a simple two item list, with bullets using the RadFlowDocument and RadFlowDocumentEditor.

Like this:-

  • Item One
  • Item Two

I have to admit it's hard going, as the documentation leaves a lot to be desired (why do none of the examples actually end up creating anything in a document?).

I currently have:-

List list = new List();
 
 newDoc.Lists.Add(list);
 
list.Levels[0].StartIndex = 1;
list.Levels[0].NumberingStyle = NumberingStyle.Bullet;
list.Levels[0].ParagraphProperties.LeftIndent.LocalValue = 24;
 
var line1=  editor.InsertLine("Line One");
line1.Paragraph.ListId = list.Id;
 
var line2=editor.InsertLine("Line Two");
line2.Paragraph.ListId = list.Id;

 

This sort of works, with the two lines being indented, but no bullet character is shown.

This thing should be simple, but isn't.

Boby
Telerik team
 answered on 26 Jun 2018
2 answers
283 views

Hi,

I'm trying to move individual blocks (BlockBase) from one document to another (RadFlowDocument). Unfortunately I get an error saying that the blocks I try to move are still related to their original document. This makes sense, because when creating a new block (both Paragraphs and Tables) you must pass a related document to the constructor. Same goes for all their children like Runs, Breaks, Rows etc.

Therefore my question - how can I copy a BlockBase from one RadFlowDocument to another? Is there a way to change this document relationship to another document?

Thanks in advance

Maks

Maksymilian
Top achievements
Rank 1
 answered on 25 Jun 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?