Telerik Forums
Telerik Document Processing Forum
8 answers
271 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
131 views

Hi,

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

/Brian 

 

 

 

Todor
Telerik team
 answered on 09 Apr 2015
2 answers
227 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
393 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
562 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
774 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
258 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
1 answer
300 views
Hi,

Is there the equivalent of wpf RadSpreadSheet in winform ?

I mean the usercontrol allowing to display data in Excel style.


Regards,

Pixie.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 30 Mar 2015
1 answer
179 views
Hi,

How do you decompress a stream now that this class is obsolete?  I used to have:

        public static byte[] Decompress(byte[] settings)
        {
            using (var zippedStream = new ZipInputStream(new MemoryStream(settings)))
            {
                return ReadFully(zippedStream);
            }
        }

        public static byte[] ReadFully(System.IO.Stream input)
        {
            var buffer = new byte[16 * 1024];
            using (var ms = new MemoryStream())
            {
                int read;
                while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
                {
                    ms.Write(buffer, 0, read);
                }
                return ms.ToArray();
            }
        }

Is it still ok to use CompressedStream directly and if so how do you create the CompressionSettings as the Method setter is protected?

Thanks,

Scott
Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
 answered on 27 Mar 2015
1 answer
425 views
Hi,

I found no direct option for Landscape formats.
So what I do ATM is to set the size with
Size sZ = PaperTypeConverter.ToSize(PaperTypes.A4);
swap width / height a this size and assign it to the page.size

Did I miss something (some "hidden" property) - or is this the way to do it?

Manfred
Tanya
Telerik team
 answered on 25 Mar 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?