Writing Excel System.Reflection.TargetParameterCountException Parameter count mismatch

I want to save some strings in excel format.

It's simple, but it doesn't work.

try

{

list.Clear();

list.Add(new string[] { "A", "B", "C", "D", "E", "F", "G" });

list.Add(new string[] { "A", "B", "C", "D", "E", "F", "G" });

list.Add(new string[] { "A", "B", "C", "D", "E", "F", "G" });

WriteExcel();

Console.WriteLine("Success");

}

catch (Exception ex)

{

Console.WriteLine("Error:" + ex.Message);

}


static void WriteExcel()

{


using (ExcelEngine excelEngine = new ExcelEngine())

{

//Set the default application version as Excel 2016

excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2016;


//Create a workbook with a worksheet

IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1);


//Access first worksheet from the workbook instance

IWorksheet worksheet = workbook.Worksheets[0];


//Insert sample text into cell “A1”

//worksheet.Range["A1"].Text = "Hello World";

worksheet.ImportData(list,1,1,true);

//Save the workbook to disk in xlsx format

Stream stm = System.IO.File.Create("filelist.xlsx");

workbook.SaveAs(stm);

stm.Close();

}

}


3 Replies 1 reply marked as answer

MA MohamedyusufKhan AhamedMusthafa Syncfusion Team September 13, 2023 01:12 PM UTC

Hi Morgan,

 

We are able to reproduce the reported issue at our end and validating it currently. We will share the validation details on September 15th, 2023.

 

regards,

 

Mohamed Yusuf Khan.



MA MohamedyusufKhan AhamedMusthafa Syncfusion Team September 20, 2023 04:51 AM UTC

Hi Morgan,

 

We have confirmed the issue in which a Parameter count mismatch exception is thrown when importing a string array through Import Data and logged a defect report. We will include the fix for this issue in our upcoming weekly NuGet release scheduled for October 3, 2023.

 

You can track the status of the bug through this link:

https://www.syncfusion.com/feedback/46995/parameter-count-mismatch-exception-is-thrown-when-importing-string-array-through

 

Regards,

Mohamed Yusuf Khan.



MA MohamedyusufKhan AhamedMusthafa Syncfusion Team October 6, 2023 02:37 AM UTC

Hi Morgan,

 

We appreciate your patience.

 

We have included the fix to resolve the issue of the Parameter count mismatch exception is thrown when importing a string array through ImportData in our weekly NuGet release version 23.1.39 Kindly

upgrade your Syncfusion packages to this new 23.1.39 version and let us know if the issue is resolved.

 

Latest NuGet Package: https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core/23.1.39

 

Regards,

Yusuf


Marked as answer
Loader.
Up arrow icon