Skale
asked on
Saving Excel workbook even the tool collapsed or thrown an error in C#
I've code like below;
GenTplParams() is writing some values on that excel file from 3rd party tool and sometimes it can crash or thrown an error while processing and when i'm getting at the end a blank excel file.
But i'd like to get the file with already written values until the crash/error occurs also it'll give me an advantage to find out which value gives an error. I can easily read the excel file and check the last value and figure out the next value has a problem.
P.S. values are getting from 3rd party softwares COM objects.
Any help makes me glad. Thank you.
if (CreateExcelFile(output_file))
{
var workbook = new ClosedXML.Excel.XLWorkbook(output_file);
// Additional to-do will list in here
GenTplParams(workbook); //This writes something in excel
workbook.SaveAs(output_file);
}
}
GenTplParams() is writing some values on that excel file from 3rd party tool and sometimes it can crash or thrown an error while processing and when i'm getting at the end a blank excel file.
But i'd like to get the file with already written values until the crash/error occurs also it'll give me an advantage to find out which value gives an error. I can easily read the excel file and check the last value and figure out the next value has a problem.
P.S. values are getting from 3rd party softwares COM objects.
Any help makes me glad. Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would rather debug the code in Visual Studio to identify problematic areas. Or look into the GenTplParams function and see if try-catch has been correctly used.
BR,
J.