Feb 16, 2015, 1:59 PM
[CLOSED] messagebox throwing null reference exception
Although I have used messagebox at many places in my code and it works fine, but it's not working at one place(below given code) and giving "null reference exception" in it.
private void LoadExcelFile(System.Windows.Forms.OpenFileDialog openFileDialog)
{
excelFile = ExcelFile.Load(openFileDialog.FileName);
// Select the first worksheet from the file.
excelWorkSheet = excelFile.Worksheets[0];
if (!IsWorkSheetEmpty(excelWorkSheet))
{
options = new ExtractToDataTableOptions(0, 0, excelFile.Worksheets[0].Rows.Count);
options.ExtractDataOptions = ExtractDataOptions.StopAtFirstEmptyRow;
options.ExcelCellToDataTableCellConverting += (sender, e) =>
{
if (!e.IsDataTableValueValid)
{
// GemBox.Spreadsheet doesn't automatically convert numbers to strings in ExtractToDataTable() method because of culture issues;
// someone would expect the number 12.4 as "12.4" and someone else as "12,4".
e.DataTableValue = e.ExcelCellValue == null ? null : e.ExcelCellValue.ToString();
e.Action = ExtractDataEventAction.Continue;
}
};
}
else
{
//X.Msg.Alert("Error", "File is Empty.").Show();
X.Msg.Show(new MessageBoxConfig
{
Title = "Error",
Message = "Excel file is empty",
Buttons = MessageBox.Button.OK
});
}
}
anyone please tell me what wrong I am doing here
Last edited by Daniil; Feb 25, 2015 at 10:13 AM.
Reason: [CLOSED]