Telerik Forums
Telerik Document Processing Forum
5 answers
188 views

Hi,

 

I wanted to ask if it is possible to rotate the text of a cell. See the screenshot for an example.

 

Best regards,

Philipp

Tanya
Telerik team
 answered on 25 Jan 2017
1 answer
159 views

Hi,

Is it possible to configure the printing as for the library RadSpreadProcessing ?

Thank you

'Print configuration
Dim pageSetup As Printing.WorksheetPageSetup = excSheet.WorksheetPageSetup
pageSetup.PaperType = Telerik.Windows.Documents.Model.PaperTypes.A4
pageSetup.PageOrientation = Telerik.Windows.Documents.Model.PageOrientation.Landscape
Dim HeadFootSettings As Printing.HeaderFooterSettings = pageSetup.HeaderFooterSettings
HeadFootSettings.Header.CenterSection.Text = excSheet.Name
HeadFootSettings.Footer.CenterSection.Text = DateTime.Now.ToString
Martin Ivanov
Telerik team
 answered on 17 Jan 2017
1 answer
206 views

Hello,

i have an issue with WordsProcessing. After i have replaced text, borders from tables disappear.

 

Public Function SetVorblatt() As String
       Dim cmsObj As New CsCms
       Dim dateiName As String = Titel.Replace(":", "").Replace("/", "").Replace("\", "").Replace("""", "")
       Dim containsAlleMa As Boolean = False
       Dim flowDocument As Telerik.Windows.Documents.Flow.Model.RadFlowDocument
       Dim docxProvider As New Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider
       Dim floDocEditor As Telerik.Windows.Documents.Flow.Model.Editing.RadFlowDocumentEditor
       Dim formulardaten As List(Of FormularData) = GetFormData()
       'Änderung vom 12.12.2016
       'Umstellung vom RTF auf DOCX
       'Änderung vom 02.09.2015
       'Prüfung, ob bei den Adressatenkreis "alle Mitarbeiter" ausgewählt wurde. Falls nicht, soll die Checkbos "wie folgend" befüllt werden
 
       Try
 
           If IsNothing(formulardaten) = False Then
               Using input As New FileStream(AppSettings("serverMappath") & "\anwendungen\zav\formulare\RL-Vorlage_.docx", FileMode.Open)
                   flowDocument = docxProvider.Import(input)
               End Using
 
               floDocEditor = New Telerik.Windows.Documents.Flow.Model.Editing.RadFlowDocumentEditor(flowDocument)
 
               For Each formData As FormularData In formulardaten
                   floDocEditor.ReplaceText(formData.Text, formData.Value & " ")
                   Logger.Trace(formData.Text & " :" & formData.Value)
               Next
 
               Using output As New FileStream(AppSettings("serverMappath") & "\anwendungen\sfo\vorblatt\" & dateiName & ".docx", FileMode.Create)
                   docxProvider.Export(flowDocument, output)
               End Using
 
               dateiName = AppSettings("serverMappath") & "\anwendungen\sfo\vorblatt\" & dateiName & ".docx"
           End If
 
       Catch ex As Exception
           Dim var As String = "Vorblatt wurde nicht erzeugt. dateiName:" & dateiName
           Logger.Error(var, ex)
       End Try
       Return dateiName
   End Function

 

You can see it at the attachements. Have anyone an idea what i have made wrong?

Best regards

Jens

Mihail
Telerik team
 answered on 16 Jan 2017
18 answers
488 views
Hi,

I am trying to replace my current zip library with Telerik's one.

My goal is to improve the transfer of huge objects between SL and WCF.
I can sucessfully zip my serialized object as in (note that I am using IsolatedStorage instead of memory stream as the objects some times are so big that using memory stream would throw an Out of Memory Exception):
public static byte[] SerializeAndCompress(T obj)
{
    var filename = DateTime.Now.ToString("ddMMYYYYhhmmss") + ".xml";
  
    var appStore = IsolatedStorageFile.GetUserStoreForApplication();
  
    if (appStore.Quota < TamanhoStorage) appStore.IncreaseQuotaTo(TamanhoStorage);
  
    byte[] bobj;
  
    using (var fileStream = appStore.OpenFile(filename, FileMode.Create))
    {
        var serializer = new DataContractSerializer(typeof(T));
        serializer.WriteObject(fileStream, obj);
  
        fileStream.Position = 0;
  
        bobj = new byte[fileStream.Length];
        fileStream.Read(bobj, 0, (int)fileStream.Length);
    }
  
    using (var fileStream = appStore.OpenFile(filename, FileMode.Create))
    {
        using (var zip = new ZipOutputStream(fileStream))
        {
            zip.Write(bobj, 0, bobj.Length);
        }
    }
  
    byte[] cobj = null;
  
    using (var fileStream = appStore.OpenFile(filename, FileMode.Open))
    {
        cobj = new byte[fileStream.Length];
        fileStream.Read(cobj, 0, cobj.Length);
    }
  
    appStore.DeleteFile(filename);
  
    return cobj;
}

This will compress my object as intended. My problem is reverting this process.
The only way I was able to achieve this was using a stream reader's ReadToEnd Method, but that won't work, as it will return a string, and I need a byte array (I know I can convert the string back to a byte array, but I'd like to make it in a better way, as in filestream.Read). Code sample:

using (var fileStream = appStore.OpenFile(filename, FileMode.Open))
    {
        using (var zip = new ZipInputStream(fileStream))
        {
            using (var sr = new StreamReader(zip))
            {
                var str = sr.ReadToEnd();
            }
        }
    }


After I call the sr.ReadToEnd method I can see the zip properties filled correctly with the compressed and uncompressed size.
What I need is the byte array of the decompressed object. Is there a way to achieve this? 

I tryed the following approach but it didn't work, as I can't foresee the size of the uncompressed object and the decompressed byte array won't be correct:

var bobj = new byte[5000000];
 
using (var fileStream = appStore.OpenFile(filename, FileMode.Open))
{
    using (var zip = new ZipInputStream(fileStream))
    {
        zip.Read(bobj, 0, (int)fileStream.Length);
 
    }
}

That will not read the decompressed object correctly, and will waste memory if the object is smaller than the byte array "bobj".

Thanks in advance.

Regards

Take Care

Jhon
Zlatko
Top achievements
Rank 1
 answered on 29 Dec 2016
1 answer
380 views

Hi,

I have Performance Issues with the Excel spreadprocessing export. I just migrated an Excel export that used until now the libraries "Component One". The export takes now 30 seconds for 7221 rows and 88 columns, against 5 seconds before. Here is the code:

001.        ... Fill the table...
002.        Using excBook As New Workbook
003. 
004.            excBook.SuspendLayoutUpdate()
005.            Using (New UpdateScope(
006.                Function() (excBook.History.IsEnabled = False),
007.                Function() (excBook.History.IsEnabled = True)))
008. 
009.                Dim excSheet As Worksheet                     
010.                excSheet = excBook.Worksheets.Add()
011.                excSheet.Name = tbl.TableName
012.                fill_ExcelSheet(tbl, excSheet)
013. 
014.            End Using
015.            excBook.ResumeLayoutUpdate()
016. 
017.            'Save the Excel-File
018.            Dim formatProvider As Telerik.Windows.Documents.Spreadsheet.FormatProviders.IWorkbookFormatProvider _
019.                = New Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider()
020. 
021.            Using fsOutput As New FileStream(strFilename, FileMode.Create)
022.                formatProvider.Export(excBook, fsOutput)
023.            End Using
024. 
025.        End Using
026. 
027.Private Shared Function fill_ExcelSheet(ByVal tblDaten As DataTable, ByVal excSheet As Worksheet) As Boolean
028.    Dim bolOK As Boolean = False
029.    Dim intCntCols As Integer, intCntRows As Integer
030.    Dim strColCaption As String
031. 
032.    Try
033. 
034.        'Set Columns-Description
035.        For intCntCols = 0 To tblDaten.Columns.Count - 1
036.            strColCaption = get_AttributCaption(tblDaten.Prefix, tblDaten.Columns(intCntCols).ColumnName)
037.            excSheet.Cells.Item(0, intCntCols).SetValue(strColCaption)
038.        Next
039. 
040.        'Fill the Sheet with data
041.        excSheet.Cells.Item(1, 0, tblDaten.Rows.Count, tblDaten.Columns.Count).SetFormat(New CellValueFormat("@"))
042.        For intCntRows = 0 To tblDaten.Rows.Count - 1
043.            For intCntCols = 0 To tblDaten.Columns.Count - 1
044.                Dim colName As String = tblDaten.Columns(intCntCols).ColumnName
045.                If (tblDaten.Columns(colName).DataType Is GetType(Date)) Then
046.                    If Not tblDaten.Rows(intCntRows).IsNull(colName) Then
047.                        If CType(tblDaten.Rows(intCntRows).Item(colName), Date).TimeOfDay.Ticks > 0 Then
048.                            excSheet.Cells.Item(intCntRows + 1, intCntCols).SetValue(CType(tblDaten.Rows(intCntRows).Item(colName), Date).ToString)
049.                        Else
050.                            excSheet.Cells.Item(intCntRows + 1, intCntCols).SetValue(CType(tblDaten.Rows(intCntRows).Item(colName), Date).ToShortDateString)
051.                        End If
052.                    End If
053.                ElseIf (tblDaten.Columns(colName).DataType Is GetType(System.Guid)) Then
054.                    excSheet.Cells.Item(intCntRows + 1, intCntCols).SetValue(tblDaten.Rows(intCntRows).Item(colName).ToString)
055.                ElseIf (tblDaten.Columns(colName).DataType Is GetType(String)) Then
056. 
057.                    excSheet.Cells.Item(intCntRows + 1, intCntCols).SetValue(tblDaten.Rows(intCntRows).Item(colName).ToString)
058.                ElseIf (tblDaten.Columns(colName).DataType Is GetType(Integer)) _
059.                    Or (tblDaten.Columns(colName).DataType Is GetType(Int16)) _
060.                    Or (tblDaten.Columns(colName).DataType Is GetType(Single)) _
061.                    Or (tblDaten.Columns(colName).DataType Is GetType(Decimal)) _
062.                    Or (tblDaten.Columns(colName).DataType Is GetType(Double)) Then
063.                    If Not tblDaten.Rows(intCntRows).IsNull(colName) Then
064.                        excSheet.Cells.Item(intCntRows + 1, intCntCols).SetValue(CDbl(tblDaten.Rows(intCntRows).Item(colName)))
065.                    End If
066.                ElseIf (tblDaten.Columns(colName).DataType Is GetType(Boolean)) Then
067.                    If Not tblDaten.Rows(intCntRows).IsNull(colName) Then
068.                        excSheet.Cells.Item(intCntRows + 1, intCntCols).SetValue(CBool(tblDaten.Rows(intCntRows).Item(colName)))
069.                    End If
070.                Else
071.                    If Not tblDaten.Rows(intCntRows).IsNull(colName) Then
072.                        excSheet.Cells.Item(intCntRows + 1, intCntCols).SetValue(tblDaten.Rows(intCntRows).Item(colName))
073.                    End If
074.                End If
075.            Next
076.            Application.DoEvents()
077.        Next
078. 
079.        'Print properties
080.        Dim pageSetup As Printing.WorksheetPageSetup = excSheet.WorksheetPageSetup
081.        pageSetup.PaperType = Telerik.Windows.Documents.Model.PaperTypes.A4
082.        pageSetup.PageOrientation = Telerik.Windows.Documents.Model.PageOrientation.Landscape
083.        Dim HeadFootSettings As Printing.HeaderFooterSettings = pageSetup.HeaderFooterSettings
084.        HeadFootSettings.Header.CenterSection.Text = excSheet.Name
085.        HeadFootSettings.Footer.CenterSection.Text = DateTime.Now.ToString
086. 
087.        If excSheet.Workbook.Styles("NormalStyle") Is Nothing Then
088.            Dim normalStyleCells As Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle = excSheet.Workbook.Styles.Add("NormalStyle")
089.            Dim borderDotCell As New CellBorder(CellBorderStyle.Hair, New ThemableColor(ThemeColorType.Text1))
090.            Dim borderThinCell As New CellBorder(CellBorderStyle.Thin, New ThemableColor(ThemeColorType.Text1))
091.            Dim fill As IFill = PatternFill.CreateSolidFill(New ThemableColor(Windows.Media.Colors.White))
092.            normalStyleCells.BeginUpdate()
093.            normalStyleCells.TopBorder = borderDotCell
094.            normalStyleCells.BottomBorder = borderDotCell
095.            normalStyleCells.LeftBorder = borderThinCell
096.            normalStyleCells.RightBorder = borderThinCell
097.            normalStyleCells.FontFamily = New ThemableFontFamily("Arial")
098.            normalStyleCells.FontSize = UnitHelper.PointToDip(8)
099.            normalStyleCells.Fill = fill
100.            normalStyleCells.EndUpdate()
101. 
102.            Dim headerStyleCells As Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle = excSheet.Workbook.Styles.Add("HeaderStyle")
103.            fill = PatternFill.CreateSolidFill(New ThemableColor(Windows.Media.Color.FromRgb(192, 192, 192)))
104.            headerStyleCells.CopyPropertiesFrom(normalStyleCells)
105.            headerStyleCells.BeginUpdate()
106.            headerStyleCells.IsWrapped = False
107.            headerStyleCells.TopBorder = borderThinCell
108.            headerStyleCells.BottomBorder = borderThinCell
109.            headerStyleCells.Fill = fill
110.            headerStyleCells.EndUpdate()
111. 
112.            Dim footStyleCells As Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle = excSheet.Workbook.Styles.Add("FooterStyle")
113.            footStyleCells.CopyPropertiesFrom(normalStyleCells)
114.            footStyleCells.BottomBorder = borderThinCell
115. 
116.            Dim leftAlignStyleCells As Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle = excSheet.Workbook.Styles.Add("LeftAlignStyle")
117.            leftAlignStyleCells.HorizontalAlignment = RadHorizontalAlignment.Left
118.            Dim rightAlignStyleCells As Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle = excSheet.Workbook.Styles.Add("RightAlignStyle")
119.            rightAlignStyleCells.HorizontalAlignment = RadHorizontalAlignment.Right
120.        End If
121. 
122.        excSheet.Columns(0, tblDaten.Columns.Count - 1).AutoFitWidth()
123.        Dim rowHeight As New RowHeight(UnitHelper.PointToDip(11.5), True)
124.        excSheet.Rows(0, tblDaten.Rows.Count).SetHeight(rowHeight)
125. 
126.        'Format cells
127.        For col As Integer = 0 To tblDaten.Columns.Count - 1
128.            'Links- oder Rechtsbündig setzen
129.            Dim strAHorz As String = "LeftAlignStyle"
130.            Dim typCol As Type = tblDaten.Columns(col).DataType
131.            If (typCol Is GetType(Integer)) Or (typCol Is GetType(Single)) Or (typCol Is GetType(Decimal)) Or (typCol Is GetType(Double)) Then
132.                strAHorz = "RightAlignStyle"
133.            End If
134. 
135.            excSheet.Cells(0, col).SetStyleName("HeaderStyle")
136.            excSheet.Cells(1, col, tblDaten.Rows.Count - 1, col).SetStyleName("NormalStyle")
137.            excSheet.Cells(tblDaten.Rows.Count, col).SetStyleName("FooterStyle")
138. 
139.            excSheet.Cells(0, col, tblDaten.Rows.Count, col).SetStyleName(strAHorz)
140.        Next
141.        bolOK = True
142.    Catch ex As Exception
143.        show_AppErrorMsgBox(ex)
144.    End Try
145.    Return bolOK
146.End Function

 

The code that takes the most time is:

 - Lines 42 - 77: Fill the sheet with data: 12 seconds
 - Line 122: AutoFitWidth(): 6 seconds --> (It's important, cannot be removed)
 - Line 22: formatProvider.Export(excBook, fsOutput): 11 seconds --> That's very long !!!

Can you check my code and tell me if there are any improvements, please? So i can unfortunately not use the libraries.

Thanks in advance

Boby
Telerik team
 answered on 27 Dec 2016
2 answers
93 views

Given a set of strings, how should I compute a pattern from it? For example, (see picture), would provide me "Cadastro de Pessoas Físicas de Inscrição  Nome  Nasc". Of course, I could do it manually by analyzing the strings, but I need an automatic procedure for it because they would be more complex. Any ideas? I realize that this issue has do more with algorythms that Telerik products themselves.

 

 

Tanya
Telerik team
 answered on 23 Dec 2016
3 answers
299 views

Hallo,

when i read the result of a cell with a formular how has a function (like SUM()) or a referenz (sheetname!Range) linked to a worksheet (itself or another) in the workbook the result (.GetResultValueAsString ) ist "0" or a text (the formular itself) and not the result. Simple formulars related to cells in the worksheet are ok.

Example:

The cell formular looks like this:

1. =SUMME(L23:L30) ==> GetResultValueAsString result = "0"

2. {=WENNFEHLER(INDEX(Bestellliste!E:E;KKLEINSTE(WENN(Bestellliste!$A$1:$A$1131="x";ZEILE($1:$991));ZEILE(A3)));"")} ==> GetResultValueAsString result = "=WENNFEHLER(INDEX(Bestellliste!E:E;KKLEINSTE(WENN(Bestellliste!$A$1:$A$1131="x";ZEILE($1:$991));ZEILE(A3)));"")"

VB code:
Dim iCellValue As ICellValue
iCellValue = TryCast(workbook.ActiveWorksheet.Cells(row, col).GetValue().Value, ICellValue)
If iCellValue IsNot Nothing Then
    Dim format As CellValueFormat = workbook.ActiveWorksheet.Cells(row, col).GetFormat().Value
    Dim valueAsString As String = iCellValue.GetValueAsString(format)
    'valueAsString
    Dim resultValueAsString As String = iCellValue.GetResultValueAsString(format)
    'resultAsString
    Dim valueType As CellValueType = iCellValue.ValueType
    'valueType = Formula      ' ==> allways Text{4} with komplex formular
    'resultValueType = Number
    Dim resultValueType As CellValueType = iCellValue.ResultValueType
End If

DLL Version: 2015.2.728.40

What's wrong? Are their any restriction to resolve formulars?

 

Regards

Harald

 

 

 

Deyan
Telerik team
 answered on 16 Dec 2016
3 answers
537 views

I'm trying to zip a PDF file, it creates zip file correctly, but if I try to open compressed PDF file, it show me error message "Corrupted file" (I'm trying to open by my PDF reader), where I wrong?

using (Stream stream = File.Open(fileFullName, FileMode.Create))
                    {
                        using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, false, null))
                        {
                            using (ZipArchiveEntry entry = archive.CreateEntry(fi.Name))
                            {
                                var writer = new StreamWriter(entry.Open());
 
                                using (Stream streamFileToZip = File.Open(fi.FullName, FileMode.Open))
                                {
                                    var buffer = new byte[4096];
                                    int sourceBytes = 0;
                                    do
                                    {
 
                                        sourceBytes = streamFileToZip.Read(buffer, 0, buffer.Length);
                                        writer.Write(buffer);
 
                                    } while (sourceBytes > 0);
 
                                }
 
                                writer.Flush();
                            }
                        }
                    }
Dario Concilio
Top achievements
Rank 2
 answered on 06 Dec 2016
1 answer
486 views

Hi !

I searching another way to generate my PDF document by WordsProcessing.

Compositing it and convert to PDF

After install by Configure project (CfgProject.png) the Document.Flow (RadWordsProcessing) when i want convert it like this sample :

Telerik Sample export to PDF

the namespace "Telerik.Windows.Documents.Flow.FormatProviders.Pdf" is not found

The dll wasn't copied by Configure project ?! (FormatProvidersPdf.png)

it's a bug ? why ?

 

Thanks.

 

Dinko | Tech Support Engineer
Telerik team
 answered on 05 Dec 2016
2 answers
446 views

Hello,

Iam creating a pdf document wherein iam trying to set the size of the RadFixedPage object but the size property is showing as 

page.Size=new System.Windows.Size()

instead of page.Size = new Size();

What am i missing ? Any reference? 

I have already included the below references on my aspx page 

using System.Windows;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export;
using Telerik.Windows.Documents.Fixed.Model;
using Telerik.Windows.Documents.Fixed.Model.ColorSpaces;
using Telerik.Windows.Documents.Fixed.Model.Editing;
using Telerik.Windows.Documents.Fixed.Model.Editing.Flow;
using Telerik.Windows.Documents.Fixed.Model.Fonts;
using Telerik.Windows.Documents.Fixed.Model.Graphics;

 

Thanks in Advance

Sushanth.B

Martin Ivanov
Telerik team
 answered on 02 Dec 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?