davidcon / excellibrary

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

Unable to read XLS file (file is corrupted) #164

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try this code 

SerializationObject.Module mod = 
XMLSerializer<SerializationObject.Module>.Deserialize("XLS_Config.XML");
            foreach (SerializationObject.Client cli in mod.clients)
            {
                String path = cli.path + cli.file_name;
                Console.WriteLine("\npath : " + cli.path + " file_name : " + cli.file_name); 
                XL.SpreadSheet.Workbook wbk = new XL.SpreadSheet.Workbook();
                foreach (SerializationObject.Sheet sh in cli.sheets)
                {
                    XL.SpreadSheet.Worksheet wbsh = new XL.SpreadSheet.Worksheet(sh.name);
                    Console.WriteLine("\nsheet_name : " + sh.name);
                    int i = 0;
                    foreach (SerializationObject.Column col in sh.columns)
                    {

                        wbsh.Cells[i, 0] = new XL.SpreadSheet.Cell(col.name);
                        Console.WriteLine("\ncol_name " + i + " : " + col.name); 
                        i++;
                        for (int cmp = 0; cmp < 100; cmp++)
                            wbsh.Cells[cmp, 0] = new XL.SpreadSheet.Cell("");
                    }
                }
                wbk.Save(path);
            }
            Console.Read();

Don't worry, I use a configuration XML file and its OK. I see this error before 
in this website but the solution doesn't works. 

What is the expected output? What do you see instead?

Excel encounter unreadable content, Do you want to recover this content ?

I clicked on Yes and, Unable to read this file, This workbook is corrupted.

What version of the product are you using? On what operating system?

I program with VS 2010, I have Excel 2007, I have Windows Seven (x64), I use 
the ExcelLibrary_20110414. 

Please provide any additional information below.

Can you answer me quickly please ? my deadline is soon.
Sorry for my bad English, I'm french.

Original issue reported on code.google.com by johan.do...@gmail.com on 18 Mar 2014 at 10:01

Attachments:

GoogleCodeExporter commented 8 years ago
the problem you are facing has to do with the fact that because the file is too 
small, it appears corrupted. Try adding a few blank cells in order to make the 
file larger. When I say blank cells I mean strings with nothing in them...empty 
strings. I noticed that the files need to be larger than 7.0 KB. I hope this 
helps

Original comment by cesar.bo...@gmail.com on 25 Jun 2014 at 8:51