We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Suppress error messages

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Is this any way to ignore all errors that are sometimes produced, for example the ‘Number stored as text’ type errors?

Thanks.

Hi,


Yes, you may use error checking options APIs.

Please see the following code. I have attached the output file for your reference generated by this code.

C#

string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook workbook = new Workbook();


Worksheet worksheet = workbook.Worksheets[0];


//Add “23” it will show number stored as text but

//after applying error checking options, it won’t show this message

worksheet.Cells[“A1”].PutValue(“23”);


Aspose.Cells.ErrorCheckOptionCollection opts = worksheet.ErrorCheckOptions;

int i = opts.Add();

Aspose.Cells.ErrorCheckOption opt = opts[i];

opt.SetErrorCheck(Aspose.Cells.ErrorCheckType.TextNumber, false);

CellArea ca = new CellArea();

ca.StartRow = 0;

ca.StartColumn = 0;

ca.EndRow = 65535;

ca.EndColumn = 255;

opt.AddRange(ca);


//Save the excel file.

workbook.Save(filePath + “.out.xlsx”);



Thanks.

Will this code apply to every worksheet or would I need to to do for each one?

Hi,

It’s a sheet based, so you will have to do it for every sheet.

Hello Shakeel

I’m having the same problem, but can’t use ErrorCheckOptionCollection.

It’s like if i lost an assembly reference… and is not probably.

And if I use PutValue method, sometime changes the values. I mean, I have 30.000% and displays 0, and when i focus the cell 0.3

Any possible solution?

thanks, Charles

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please download and use the latest version:
Aspose.Cells
for .NET v7.1.2.4



For your needs, I have created a sample that demonstrates how to add 0.3 value and display it as 30.000%.

Please see the code below. I have also attached the output file and the screenshot.

C#


Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

Cell cell = worksheet.Cells[“A1”];

cell.PutValue(0.3);

Style style = cell.GetStyle();

style.Custom = “0.000%”;

style.CultureCustom = “0.000%”;

cell.SetStyle(style);

workbook.Save(@“c:\output.xlsx”);

Screenshot