Telerik Forums
Telerik Document Processing Forum
1 answer
278 views
hi,

I'm trying to import an existing word template into a RadFlowDocument, edit it by filling the merge fields and display it on the screen (read-only).
Can anyone please assist me with this. The word templates also contains a header, which contains images and text boxes.
The File.OpenRead command returns an error, as it is unable to read the document into a stream (object reference not set to an instance of an object).
Petya
Telerik team
 answered on 21 Oct 2014
1 answer
318 views
Hi,

When I generate a Worksheet with foreground colors for every row this is slow for small Excel files (say 1000 rows and 25 columns) and runs out memory for a 4000 row by 25 column Excel (the .xls file without the colors is about 400k). When I comment out the color code below it is significantly faster (about 5 times) and doesnt run out of memory.

Regards,

Bayram


private static Workbook CreateWorkbook(RadGridView grid, IEnumerable<string> skipColumns)
{
    Workbook book = new Workbook();
    book.Sheets.Add(SheetType.Worksheet);
    Worksheet sheet = book.ActiveWorksheet;
 
    Color accentBorder = Office2013Palette.Palette.AccentColor;
    Color transparent = Colors.Transparent;
    Color black = Colors.Black;
    Color white = Colors.White;
 
    ThemableColor themeBlack = new ThemableColor(Color.FromArgb(0,0,0,0));
    ThemableColor themeWhite = new ThemableColor(Color.FromArgb(0, 255, 255, 255));
 
    CellBorder border = new CellBorder(CellBorderStyle.Thin, themeBlack);
    CellBorder noBorder = new CellBorder(CellBorderStyle.None, themeBlack);
    CellBorders borders = new CellBorders(border, border, border, border, border, border, noBorder, noBorder);
 
    int rowNumber = 0;
    int colNumber = 0;
    foreach (var column in grid.Columns)
    {
        if (column.Header is string)
        {
            string columnHeader = (string)column.Header;
            if (skipColumns == null || !skipColumns.Contains(columnHeader))
            {
                sheet.Cells[rowNumber, colNumber].SetValue(columnHeader);
                colNumber++;
            }
        }
    }
    CellSelection selection = sheet.Cells[0,0,0,colNumber-1];
    selection.SetIsBold(true);
    PatternFill solidPatternFill = new PatternFill(PatternType.Solid, accentBorder, transparent);
    selection.SetFill(solidPatternFill);
    selection.SetForeColor(themeWhite);
 
    HashSet<int> textColumns = new HashSet<int>();
    rowNumber++;
    foreach (var item in grid.Items)
    {
        if (item is DynRecord)
        {
            DynRecord record = (DynRecord)item;
            colNumber = 0;
 
            foreach (var column in grid.Columns)
            {
                if (column.Header is string)
                {
                    string columnHeader = (string)column.Header;
                    if (skipColumns == null || !skipColumns.Contains(columnHeader))
                    {
                        if (column is GridViewDataColumn)
                        {
                            GridViewDataColumn dataColumn = (GridViewDataColumn)column;
                            string propName = dataColumn.DataMemberBinding.Path.Path;
 
                            object value = record.Value(propName);
                            if (value != null)
                            {
                                if (value is string)
                                {
                                    textColumns.Add(colNumber);
                                    sheet.Cells[rowNumber, colNumber].SetValue((string)value);
                                }
                                else if (value is DateTime)
                                    sheet.Cells[rowNumber, colNumber].SetValue((DateTime)value);
                                else if (value is Decimal)
                                    sheet.Cells[rowNumber, colNumber].SetValue(Convert.ToDouble((decimal)value));
                                else
                                {
                                    textColumns.Add(colNumber);
                                    sheet.Cells[rowNumber, colNumber].SetValue(value.ToString());
                                }
                            }
                        }
                        colNumber++;
                    }
                }
            }
            // This part is slow and runs out of memory
            //Color color = record.GetRecordColor().Color;
            //if (color != Colors.Black)
            //{
            //    selection = sheet.Cells[rowNumber, 0, rowNumber, colNumber - 1];
            //    selection.SetForeColor(new ThemableColor(color));
            //}
 
            rowNumber++;
        }
    }
    selection = sheet.Cells[0, 0, rowNumber-1, colNumber - 1];
    selection.SetBorders(borders);
 
 
    // Set Text columns formatting to @ to prevent Excel autoformatting
    foreach (int i in textColumns)
    {
        selection = sheet.Cells[1, i, rowNumber - 1, i];
        selection.SetFormat(new CellValueFormat("@"));
    }
 
    // AutoFitWidth
    for (int i = 0; i < colNumber - 1; i++)
    {
        ColumnSelection columnSelection = sheet.Columns[i];
        columnSelection.AutoFitWidth();
        double width = sheet.Columns[i].GetWidth().Value.Value * 1.1;
        columnSelection.SetWidth(new ColumnWidth(width, false));
    }
 
    return book;
}
Anna
Telerik team
 answered on 17 Oct 2014
1 answer
124 views
In excel you can open a document and go to File->Properties where in custom tab you can enter a custom property (with value) to the document.

Is it possible to do this in an excel workbook created with SpreadProcessing?
Nikolay Demirev
Telerik team
 answered on 10 Oct 2014
5 answers
203 views
Hi,

Setting:

TextProperties.Font = FontsRepository.Helvetica

Editor.DrawText("æøåÆØÅ")

Gives an error

Any setting for nordic letters I am missing?

Regards,
Brian
Kammen
Telerik team
 answered on 30 Sep 2014
1 answer
95 views
Hi,

When trying to overwrite an already created pdf file using the following code:

      Dim OutStream As New FileStream(Me.FileName, FileMode.Create)
      PdfFormatProvider.Export(Me.PDFDocument, OutStream)
      OutStream.Close()

I get an error "File is being used by an other process"

What do I miss in ending the first operation?

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
74 views
Hi,

Using Clipping and having defined a clipping rectangle: I am searching for a "IsVisible" function like the one in System.Drawing.Graphics.

The purpose is to reduce file size by excluding eg. text, which will not be visible because of the clipping.

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
194 views
Hi,

I would like to apply multiple transformation to FixedContentEditor.Position

However, the MatrixPosition class seems not to apply to the FixedContentEditor

And eg. the Editor.Position.Matrix.TranslatePrepend function does not seem to work, because Editor.Position.Matrix is readonly.

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
607 views
Hi,

Your example shows how to insert jpg image from file:

Using stream As Stream = Me.GetResourceStream("Telerik_logo.jpg")
editor.DrawImage(stream, ImageFormat.Jpeg, New Size(118, 28))
End Using

I would like to insert image from .NET Image class variable. The images are stored in Base64 format in a database.

Could you provide a code snippet for that?

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
174 views
I'm trying to evaluate the functionality available with your pdfviewer and this pdfprocessing component.  I can't locate the pdfprocessing class or namespace and I can't find any documentation on it.  Can someone provide an example of how to use the pdfprocessing component to extract images from a pdf file?
Petya
Telerik team
 answered on 23 Sep 2014
2 answers
1.3K+ views
I write content to a cell that is by default interpreted as a date.
But I want it treated as plain text.
How do I do this? The CellValueFormat constructor wants a format string; but there is no format string for this case.
Marc
Top achievements
Rank 1
 answered on 15 Sep 2014
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?