hodzung / excellibrary

Automatically exported from code.google.com/p/excellibrary
1 stars 0 forks source link

Example code doesnt work in C# application .NET framework 2.0 #122

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I use the following code taken from this website, in a static class method.

//create new xls file
string file = "C:\\newdoc.xls";
Workbook workbook = new Workbook();
Worksheet worksheet = new Worksheet("First Sheet");
worksheet.Cells[0, 1] = new Cell((short)1);
worksheet.Cells[2, 0] = new Cell(9999999);
worksheet.Cells[3, 3] = new Cell((decimal)3.45);
worksheet.Cells[2, 2] = new Cell("Text string");
worksheet.Cells[2, 4] = new Cell("Second string");
worksheet.Cells[4, 0] = new Cell(32764.5, "#,##0.00");
worksheet.Cells[5, 1] = new Cell(DateTime.Now, @"YYYY\-MM\-DD");
worksheet.Cells.ColumnWidth[0, 1] = 3000;
workbook.Worksheets.Add(worksheet);
workbook.Save(file);

I try to open the C:\newdoc.xls file using Excel 2010 and get the error "Excel 
found unreadable content in newdoc.xls. Do you want to recover the contents of 
this workbook?"

I've also tried different code to write just a few numbers to some cells. This 
resulted in a different error message when trying to open the file "The file 
you are trying to open TempStructures.xls is in a different format than 
specified by the file extension. Verify that the file is not corrupted and is 
from a trusted source before opening the file". When I proceed to open the 
file, it appears corrupted.

I'm using Visual Studio 2008 Pro on WinXP Pro SP3, English edition.

Original issue reported on code.google.com by bigcivil...@gmail.com on 27 Feb 2012 at 3:58

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, this appears to be a duplicate of issue 102.

Original comment by bigcivil...@gmail.com on 27 Feb 2012 at 4:23

GoogleCodeExporter commented 9 years ago

Original comment by jetcat on 1 Mar 2013 at 11:00