Problems trying to save

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.

Hi Laurent,

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

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.

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.

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.

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.

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.

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?


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.

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.

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

@Josh_Gallagher,
Aspose.Cells is our new flagship product which has replaced Aspose.Excel. This new product is capable of performing all the tasks which were performed by its predecessor Aspose.Excel along with support for the latest features of MS Excel. Aspose.Cells can be used to save the Excel file to a number of formats and can be saved to response object as shown below:

HttpResponse Response = null;

// Load your source workbook
Workbook workbook = new Workbook();

if (Response != null)
{
    // Save in Excel2003 XLS format
    workbook.Save(Response, dataDir + "output.xls", ContentDisposition.Inline, new XlsSaveOptions());
	Response.End();
}

You can visit the following article for more details about saving Excel file to Response object in different formats:
Saving File to Response Object

For testing purpose you may download the latest version of the product here:
Aspose.Cells for .NET (Latest Version)

We have prepared a detailed project which provides hundreds of example demonstrating different features of Aspose.Cells. You may download it here.