We are using Aspose.Cells(4.4.0.5). I am trying to upgrade to Aspose.Cells(8.0.1.0) I got lot of errors like Error520Warning as Error: ‘Aspose.Cells.Workbook.Save(string, Aspose.Cells.FileFormatType)’ is obsolete: 'Use Workbook.Save(string,SaveFormat) method instead.
workBook.Save(filePath, FileFormatType.Default); this is the code i use, shall i use workBook.Save(filePath, SaveFormat.Auto); instead?
‘Aspose.Cells.Cell’ does not contain a definition for ‘Style’ and no extension method ‘Style’ accepting a first argument of type ‘Aspose.Cells.Cell’ could be found (are you missing a using directive or an assembly reference?)
Yes, please use workBook.Save(filePath, SaveFormat.Auto) now.
For Style, please use Cell.GetStyle() and Cell.SetStyle() methods now.
Please let us know on which type of code you are getting this error (‘Aspose.Cells.Cell’ does not contain a definition for ‘Style’) so that we could guide you better.
Using the newer versions, you will use the following lines to make the cell text bold.
e.g
Sample code:
Style style = WorkSheet.Cells[“A1”].GetStyle();
style.Font.IsBold = true;
WorkSheet.Cells[“A1”].SetStyle(style);
For your information, while trying to keep the API as straightforward and clear as possible, we decided to recognize and honor the common development practices of the platform. Therefore, Aspose.Cells for .NET follows coding guidelines widely accepted by .NET developers. With the release of Aspose.Cells for .NET version v5.0.0, we have re-organized the API classes for Aspose.Cells component. This change has some major aspects that we follow. We have added new namespaces. All the API (classes, interfaces, enumerations, structures etc.) were previously located in the Aspose.Cells namespace. Now, certain sets of API have been moved to their relative namespaces, which make the relationship of classes (with their members) and namespaces clear and simplified.
Let me come towards your significant errors that you might encounter while upgrading to new versions of the product, so you can fix them accordingly:
1) You need to import the relevant namesapaces to your demo pages or use fully qualified naming when declaring objects for classes etc.:
e.g
using System;
using System.Web;
using Aspose.Cells;
using Aspose.Cells.Pivot;
etc.
2) Some classes are renamed especially collection classes. e.g
i) Validations → ValidationCollection
ii) PivotTable → PivotTableCollection
etc.
3) Aspose.Cells.Style property is eliminated/obsoleted now, you should adjust your code to use Aspose.Cells.GetStyle() and Aspose.Cells.SetStyle() methods/ approach, it will also enhance the performance to certain extent:
e.g
Your sample code using Style attribute should be updated accordingly, e.g