This is a migrated thread and some comments may be shown as answers.
Numeric format lost on import
2 Answers 14 Views
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 13 May 2016, 02:17 PM

I'm generating spreadsheets server-side, and with the Kendo spreadsheet now available, would like to make those visible in the browser rather than having the client download the file. The spreadsheets are being created by the open source EPPlus library. I'm not having difficulty showing the spreadsheet, but it's displaying incorrectly.

When doing a server-side import, the number formatting in the cells is lost during the ToJson call back to the client. This can be seen in the Server Import/Export Demo as well. The correct numeric values are present, but their display is wrong. 

I'm sending the data back to the server with

public ActionResult GetSpreadsheet(string fname)
{
   Stream stream = ReportsController.GetStreamFromCache(fname);
 
   if (stream != null)
   {
      Workbook workbook = Workbook.Load(stream, Path.GetExtension(fname));
      return Content(workbook.ToJson(), MimeTypes.JSON);
   }
 
   return new EmptyResult();
}

I've attached a spreadsheet that is showing the problem. It displays correctly in Excel on opening.Oddly enough, I haven't seen anyone mention this on the forums, so I'm wondering if it's something with my spreadsheets.Ideally, I'd use the Workbook object on the server to create the spreadsheets, but we have entirely too many already written to convert.

Thanks for any help you can give.

 

2 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 2
answered on 13 May 2016, 03:09 PM

A little more info -- generating a PDF from this spreadsheet works perfectly, so I don't believe it's the spreadsheet.

public ActionResult PDF(string fname)
{
   Stream dataStream = ReportsController.GetStreamFromCache(fname);
 
   if (dataStream != null)
   {
      Workbook workbook = Workbook.Load(dataStream, Path.GetExtension(fname));
      Telerik.Windows.Documents.Spreadsheet.Model.Workbook document = workbook.ToDocument();
 
      using (MemoryStream outputStream = new MemoryStream())
      {
         PdfFormatProvider provider = new PdfFormatProvider();
         provider.Export(document, outputStream);
 
         return File(outputStream.ToArray(), MimeTypes.PDF, $"{Path.GetFileName(fname)}.pdf");
      }
   }
 
   return new EmptyResult();
}

 

0
Alex Gyoshev
Telerik team
answered on 17 May 2016, 08:30 AM

Hello Michael,

Thank you for the excel file -- we have reproduced the issue on our side and it has been logged for investigation.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Asked by
Michael
Top achievements
Rank 2
Answers by
Michael
Top achievements
Rank 2
Alex Gyoshev
Telerik team
Share this question
or