Telerik Forums
Telerik Document Processing Forum
2 answers
186 views

I need to save a compressed byte stream in to a database table, the problem is that whenever i open the file, winZip/winRar/windows reports that the archive is corrupt. I've tried setting leavOpen on the ZipArchive (as suggested in some other posts) but it make no difference.

any ideas?

        private byte[] Compress(byte[] pData, string pFileName)
        {
            CompressionSettings lSettings = new LzmaSettings();

            using (MemoryStream lMemoryStream = new MemoryStream()) {
                using (ZipArchive lArchive = new ZipArchive(lMemoryStream, ZipArchiveMode.Create, false, null)) {
                    ZipArchiveEntry lAttachment = lArchive.CreateEntry(pFileName, lSettings);                   
                    using (var lAttachmentStream = lAttachment.Open()) {
                        using (var lStreamWriter = new StreamWriter(lAttachmentStream)) {
                            lStreamWriter.Write(pData);
                        }
                    }
                }
                return lMemoryStream.ToArray();
            }
        }

Jason
Top achievements
Rank 1
 answered on 04 May 2015
2 answers
139 views

The ScaleFactor property of the WorksheetPageSetup class requires a System.Windows.Size  of the WindowsBase, Version=4.0.0.0 assembly.

The WindowsBase assembly does not seem to exist in .Net 4

Where can I find this assembly?

 

Petya
Telerik team
 answered on 30 Apr 2015
4 answers
312 views

Hello. I am trying to set a default height using the following code:

worksheet.DefaultRowHeight = new RowHeight(UnitHelper.PointToDip(13),true);

 

But it is not working. How can I set it up? Thank you.

cesar
Top achievements
Rank 1
 answered on 24 Apr 2015
8 answers
199 views
Hi.

I have recently started using the ZipLibrary and I am facing an Issue when adding streams to a ZipPackage.

Here is my code below, aswell as the stack trace. Is there anything wrong with it or is it an issue from the ZipLibrary ?

MemoryStream memStream = new MemoryStream();
ZipPackage Package = ZipPackage.Create(memStream);
foreach (MyItem item in myCollection) {
    Stream stream = default(Stream);
    byte[] bData = GetPdfBytes(item);
    //Average size is {Length=3150000}
    stream = new MemoryStream(bData);
    Package.AddStream(stream, string.Format("MyFileName_{0}.pdf", item.UniqueID), Telerik.Web.Zip.CompressionType.Default, item.Date);
    //Out of memory exception here
//offset: 65855158, Headers: 23, ZipPackageEntries: 23             
}
 
//Code from Telerik Samples
SendZipToClient(memStream, Package);

Stack Trace: 

at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at Telerik.Web.Zip.ZipOutputStream.StreamCopy(Stream dstStream, Stream srcStream, UInt32 len)
at Telerik.Web.Zip.ZipOutputStream.WriteCompressedData(ZipPackageEntry item)
at Telerik.Web.Zip.ZipOutputStream.AddCompressed()
at Telerik.Web.Zip.ZipOutputStream.Close(Boolean shouldCloseStream)
at Telerik.Web.Zip.ZipOutputStream.Close()
at Telerik.Web.Zip.ZipPackage.AddEntry(ZipCompression method, Stream recordStream, String fileNameInZip, DateTime dateTime, CompressionType compressionType)
at Telerik.Web.Zip.ZipPackage.AddStream(Stream stream, String fileNameInZip, ZipCompression method, DateTime dateTime)
at MyCode.DownloadZip_Click() 

Additionnal Infos:
.NET version: 4.5
Telerik version for ASP.NET AJAX: 2013.1.417.45
Phil
Top achievements
Rank 2
 answered on 16 Apr 2015
1 answer
114 views

Hi,

Is it possible to add text with outline (halo) ?

/Brian 

 

 

 

Todor
Telerik team
 answered on 09 Apr 2015
2 answers
190 views
Hello,

I am investigating RadFlowDocument as a possible reporting tool. I can load a existing document and add content but I can`t find a way to insert my content at the end of the document.  What is the best way to navigate a document with RadFlowDocumentEditor?

Thanks, Dan
Dan
Top achievements
Rank 1
 answered on 07 Apr 2015
1 answer
340 views

Hi,

 I have Performance Issues with the Excel spreadprocessing export. To populate a 1000x1000 matrix takes 70 seconds.

Can you please have a look? Thank you!

 

namespace WpfApplication1
{
    public partial class MainWindow : Window
    {
        private readonly int SIZE = 1000;

        public MainWindow()
        {
            
            InitializeComponent();

            WorkbookFormatProvidersManager.RegisterFormatProvider(new XlsxFormatProvider());
            test();

        }

        public object[,] populateData()
        {
           
            var res = new object[SIZE,SIZE];


            for(int row=0;row<SIZE;row++)
                for(int col=0;col<SIZE;col++)
                    res[row,col] = row+col;

            return res;

        }

        public void test()
        {
            Stopwatch s = Stopwatch.StartNew();
            var sensorDataTable = populateData();
           
            s.Stop();
            Console.WriteLine(string.Format("populate {0} items: {1}ms", SIZE*SIZE, s.ElapsedMilliseconds));

            s = Stopwatch.StartNew();
            Telerik.Windows.Documents.Spreadsheet.Model.Workbook workbook = new Telerik.Windows.Documents.Spreadsheet.Model.Workbook();
            using (new UpdateScope(workbook.SuspendLayoutUpdate, workbook.ResumeLayoutUpdate))
            {
                using (new UpdateScope(
                    () => { workbook.History.IsEnabled = false; },
                    () => { workbook.History.IsEnabled = true; }))
                {
                    workbook.Sheets.Add(SheetType.Worksheet);
                    Telerik.Windows.Documents.Spreadsheet.Model.Worksheet worksheet = workbook.ActiveWorksheet;

                    for(int row=0;row<SIZE;row++)
                        for(int col=0;col<SIZE;col++)
                            worksheet.Cells[row, col].SetValue(sensorDataTable[row, col].ToString());

                    worksheet.Columns[worksheet.UsedCellRange].AutoFitWidth();
                }
            }

            String filename = @"c:\test.xlsx";

            IWorkbookFormatProvider formatProvider = WorkbookFormatProvidersManager.GetProviderByName("XlsxFormatProvider");
            using (var stream = new FileStream(filename, FileMode.CreateNew, FileAccess.ReadWrite))
            {
                formatProvider.Export(workbook, stream);
            }
            s.Stop();
            Console.WriteLine(string.Format("create and save excel: {0}ms", s.ElapsedMilliseconds));
        }

    }
}


Nikolay Demirev
Telerik team
 answered on 06 Apr 2015
4 answers
509 views
 I have been using radspreadsheet for reading .csv files for some time now.  I am now working on an application that requires me to read .xslx files.  The only issue I have is the following: When reading percentage values, if the values are too small, I get a zero returned for the cell value.  For example, if my spreadsheet is:

0.10% 
1.00%
10.00%
100.00%

when reading the values, where the cell format is "percentage", I get the following values:
0
0.01
0.1
1

On the spreadsheet, I have the number of decimal points set to 6.

        private string GetCellValue(Worksheet ws, int RowIndex, int ColumnIndex)
        {
            CellSelection cell;
            ICellValue value;
            string cellvalue = "0";
            cell = ws.Cells[RowIndex, ColumnIndex];
            value = cell.GetValue().Value;
            if (value != null) cellvalue = value.RawValue.ToString();












Innermedia
Top achievements
Rank 2
 answered on 06 Apr 2015
1 answer
683 views
I try to convert an xlsx file to pdf. To do that I use WorkbookFormatProvidersManager.Import and export.
Thus, I declare 
using Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml;
using Telerik.Windows.Zip;
But I obtain a reject at compile time on the instruction 
 WorkbookFormatProvidersManager.RegisterFormatProvider(new XlsxFormatProvider());

XlsxFormatProvider is not found.
Where am'i wrong ?
Thanks for a reply.
Todor
Telerik team
 answered on 03 Apr 2015
3 answers
194 views
Since ZipPackage is now deprecated, is there a replacement to the IsZipFile method?  I haven't come across anything in the documentation yet...
Pavlina
Telerik team
 answered on 31 Mar 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?