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

Free Support Forum - aspose.com

About Workbook Constructor Issue

Hi Aspose Team

below is my Origan code:

Workbook m_Workbook = new Workbook();

m_Workbook.Settings.ConvertNumericData = false;

m_FileFormatType = FileFormatType.Excel97To2003;

m_Workbook.Open(fileName, m_FileFormatType);

Here is the new code form Aspose Workbook class suggest:
public void Open(string fileName, FileFormatType type);
[Obsolete("Use Workbook(string,TxtLoadOptions) constructor method instead.")]

TxtLoadOptions m_tLoadOpt = new TxtLoadOptions(LoadFormat.Excel97To2003);

m_tLoadOpt.ConvertNumericData = false;

Workbook m_Workbook = new Workbook(m_FileName, m_tLoadOpt);

but when program runtime, it shows the Error

NullException : Object reference not set to an instance of an object.

Please suggest


Hi Ray,

Thank you for contacting Aspose support.

Please use the LoadOptions class instead of TxtLoadOptions class because the later one is supposed to be used for loading text files such as CSV. Please check the below provided code snippet for better elaboration.


LoadOptions m_tLoadOpt = new LoadOptions(LoadFormat.Excel97To2003);
m_tLoadOpt.ConvertNumericData = false;
Workbook m_Workbook = new Workbook(myDir + “output.xls”, m_tLoadOpt);

Please feel free to write back in case you have any concerns or ambiguity.

Hi Support Team,

Thanks for your quickly response, and it works well now


Hi Ray,

Good to know that you are up and running again. Please feel free to write back anytime in case you need our further assistance.