Home » excel » disable Excel "numbers stored as text " warnings via C# code

disable Excel "numbers stored as text " warnings via C# code

Posted by: admin May 14, 2020 Leave a comment


I’m using this code to convert a CSV file to an xls file:

 Spire.Xls.Workbook workbook = new Spire.Xls.Workbook();
 workbook.LoadFromFile(path + @".csv", ",", 1, 1);
 Spire.Xls.Worksheet sheet = workbook.Worksheets[0];
 workbook.SaveToFile(path + @".xls");

The generated excel file contains “Numbers Stored as Text” warnings.

I want to ignore/disable all these warnings from C# code.

How do I do this?

How to&Answers:

I found the solution!

using Excel = Microsoft.Office.Interop.Excel;

Excel.Application app= new Excel.Application();
app.ErrorCheckingOptions.BackgroundChecking = false;//This line disable error checking
Excel.Workbook wb = app.Workbooks.Open(path, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true);
wb.Close(true, url, null);