Write to Excel Error

  1. visual studio 2010
  2. Microsoft Office 2010

Hi,everyone,I have a problem using Aspose.

I want to write some numbers into an Excel,look at the code below:
-----------------------------------------------------------------------------------------------
string templatePath = Server.MapPath("~/Template/123.xls");

Workbook workbook = null;

workbook = new Workbook(templatePath);

Worksheet workSheet = workbook.Worksheets[0];

decimal _value = decimal.Parse("6000000.5");//7668870.55
decimal _value0 = decimal.Parse("6000000.50");

float dou = 7668870.55F;
workSheet.Cells[0, 0].PutValue(_value);

workSheet.Cells[0, 1].PutValue(_value0);

workSheet.Cells[0, 2].Value = dou;

SaveFormat fileFormat = SaveFormat.Auto;
fileFormat = SaveFormat.Excel97To2003;

System.IO.MemoryStream stream = new System.IO.MemoryStream();
workbook.Save(stream, fileFormat);

Response.Clear();

Response.AppendHeader("Content-Disposition", "attachment;filename=wanda.xls");

Response.ContentType = "application/octet-stream";

Response.BinaryWrite(stream.ToArray());
------------------------------------------------------------------------------------
Excel has the wrong value:
_value ---->-4737417.74
_value0---->-4737417
dou---->-3068548

When I tried some other numbers,it worked fine.

I found that the problem may be [template]
When the numbers are in the same line,error
not in the same line , right
Any help is appreciated!
Thanks very much!
Very important!

Hi,


I have tested your scenario creating a new workbook and filling your mentioned data to it, it works fine. I am using latest fixed version v6.0.1.3 ( Please download: Aspose.Cells for .NET v6.0.1.3.). It works fine.

I have also attached the output file here for your reference.

Sample code:

Workbook workbook = null;
workbook = new Workbook();//templatePath);
Worksheet workSheet = workbook.Worksheets[0];
decimal _value = decimal.Parse(“6000000.5”);//7668870.55
decimal _value0 = decimal.Parse(“6000000.50”);
float dou = 7668870.55F;
workSheet.Cells[0, 0].PutValue(_value);
workSheet.Cells[0, 1].PutValue(_value0);
workSheet.Cells[0, 2].Value = dou;
SaveFormat fileFormat = SaveFormat.Auto;
fileFormat = SaveFormat.Excel97To2003;
//System.IO.MemoryStream stream = new System.IO.MemoryStream();
//workbook.Save(stream, fileFormat);
workbook.Save(“e:\test2\writingexcel.xls”, fileFormat);

If you still find the issue, attach your template file here, we will check your issue soon.


Thank you.