Problems trying to save


#1

I’m trying your product on demo version (web) and encounter a pb on calling the save method this way :

excel.Save(strFileExcel, Aspose.Excel.SaveType.OpenInBrowser, Aspose.Excel.FileFormatType.Excel2000, Response);

In fact, it works properly when i initialize cells until column 21. It seems it fails when i write in columns 22 or more.
The error message is “the object must be of byte type” (function Save called).
I open an existing template to build my file and columns are of standard type.

Thanks for your help,
Laurent.


#2

Hi Laurent,

Could you post your code here? Thus I can see what caused your problem.


#3

Here is my code :

// Instanciate and open template
Excel excel = new Excel();
excel.Open(Server.MapPath(strFileTemplate));

// Creating sheet (by copy of 1st sheet)
int nCurrentSheet = excel.Worksheets.AddCopy(0);

// Filling cells (in a for loop)

excel.Worksheets[nCurrentSheet].Cells[CurrentLine, 19].PutValue(p.RespAF); // p.RespAF is a string, it works


excel.Worksheets[nCurrentSheet].Cells[CurrentLine, 22].PutValue(p.ProcDev.ToString()); // p.ProcDev is still a string I cast to be sure (?) -> Save call gives error

// Next colums make Save call give error (23…24)



// Save and send to client
excel.Save(strFileExcel, Aspose.Excel.SaveType.OpenInBrowser, Aspose.Excel.FileFormatType.Excel2000, Response);


I’m fearing a pb with my template file but… the columns are of standard type.

-------------------------------------------------------------------
Thanks for your help,
(nice component anyway),
Laurent.


#4

Sorry for the problem, Laurent.

I also think it may be caused by the designer file. Could you email the file to me? And your project if possible.


#5

Oups, perhaps a silly question : do I absolutly need to used the speadsheet designer to create my templates ?
In fact, I’ve built my template with Excel 2000 (french release !?!). Where can I find this designer if needed ?

Thanks,
Laurent.


#6

You don’t need any special things to do the designer. We call the template file as designer file because you can design the whole structure in your template using MS Excel. That can greatly facilitate your program development.

So please send me your template file that you are using now and the project which detected your problem.


#7

I emailed you my files yesterday evening…

In fact, it seems I mistake using the AddCopy function.
Here is a piece of my tries :

DateTime dt1 = DateTime.Now;

// Instanciation de l’objet
Excel excel = new Excel();

// Ouverture du fichier existant
excel.Open(“C:\temp\TemplatePDC.xls”);

// Using AddCopy Here
int nIndex = excel.Worksheets.AddCopy(0);

// Ecriture dans les cellules
Worksheet sheet = excel.Worksheets[nIndex];
Cells cells = sheet.Cells;
cells[10,10].PutValue(“TEST”); // Wrong use here ??


// Header
sheet.PageSetup.SetHeader(0, “&P&“Arial,Bold”&8Et voila !”);

// Fermeture et enregistrement du fichier
excel.Save(“C:\temp\Resultat.xls”,FileFormatType.Excel2000);

DateTime dt2 = DateTime.Now;
MessageBox.Show(this, “Début:”+dt1.ToLongTimeString().ToString()
+"\nFin:"+dt2.ToLongTimeString().ToString());

Laurent.


#8

Laurent,

I don’t think your code has any problems and it works fine in my machine. Have you gotten my email and tried the fix 1.8.4.1?


#9


Yes, I’ve just trying the new release : it seems everything is ok now !
(In fact, it looks like the problem was when I make an Excel template with Ctrl+A and all cells set at font size 8…).

Thanks you very much !

Laurent.


#10

I think my problem with the width adjustment and Worksheet.AddCopy() is the same issue as this one. If I create a new worksheet, Ctrl-A and change the font size (thus automatically changing all the row heights) I get the same failure as when I change the column width of the first column.


#11

It’s fixed. Please download fix 1.8.5 and have a try.