Hi Ahmed,
Greetings from Syncfusion.
The Excel document you have shared us in seems to be corrupted. We request you to share the issue reproducing sample along with the Excel document, to investigate the query and provide prompt solution at the earliest.
Also, please confirm the Syncfusion XlsIO version you are using at your end.
Regards,
Keerthi.
1- The Excel file is not the problem, however, I've attached a new one.
2- XlsIO version is "18.3460.0.35".
2- In the Excel file these cells (A4, A5, A6, A8) are pasted (as plain text) from another Excel file and they are causing the #VALUE error when I read them.
3- Below is my code:
var options = new ExcelExportingOptions();
options.ExportMode = ExportMode.Text;
options.ExcludeColumns.Add("Action");
options.ExcludeColumns.Add("Action2");
var excelEngine = DgEmails.ExportToExcel(DgEmails.View, options);
var workBook = excelEngine.Excel.Workbooks[0];
workBook.ActiveSheet.UsedRange.AutofitColumns();
workBook.ActiveSheet.UsedRange.NumberFormat = "@";
workBook.ActiveSheet.Rows[0].CellStyle.Color = Color.Gray;
workBook.ActiveSheet.Rows[0].CellStyle.Font.Color = ExcelKnownColors.White;
workBook.ActiveSheet.Rows[0].CellStyle.Font.Bold = true;
try
{
workBook.SaveAs(dlg.FileName);
MessageBox.Show(this, "تم حفظ الملف بنجاح.", "تصدير قائمة البريد",
Msgs.btnOk, Msgs.icnInf, Msgs.defBtn1, Msgs.opt);
}
catch (Exception ex)
{
if (ex.Message.Contains("cannot access the file"))
{
MessageBox.Show(this, "الملف المحدد قيد الاستخدام، قم بإغلاق الملف
المحدد أو قم بتغيير اسم الملف.", "خطأ أثناء التصدير", Msgs.btnOk,
Msgs.icnErr, Msgs.defBtn1, Msgs.opt);
}
}
workBook.Close();
excelEngine.Dispose();
Import ----------------------
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook xls = application.Workbooks.Open(dlg.FileName);
for (int i = 1; i < xls.ActiveSheet.Rows.Count() - 1; i++)
{
DsEmails.Tables["StoresEmails"].Rows.Add(
xls.ActiveSheet.GetText(i,0),
xls.ActiveSheet.GetText(i, 1),
xls.ActiveSheet.GetText(i, 2),
xls.ActiveSheet.GetText(i, 3)
);
}
DsEmails.AcceptChanges();
xls.Close();
excelEngine.Dispose();
Attachment:
JupiterEmailsList_94334f89.rar