System.Reflection.TargetParameterCountException: Parameter count mismatch

var dataToUpload = new List<BsonDocument>();

Workbook book = new Workbook(new MemoryStream(buffer));
Worksheet sheet = book.Worksheets[sheetName];

ImportTableOptions imp = new ImportTableOptions();
imp.InsertRows = true;
imp.IsFieldNameShown = true;
sheet.Name = sheetName;
sheet.Cells.ImportCustomObjects(dataToUpload, startRow, startColumn, imp);
book.Worksheets[sheetName].AutoFitColumns();

im getting this issue using this code my input dataToUpload is List<BsonDocument>
e.g {"key","value"}

but its giving me this error below
System.Reflection.TargetParameterCountException: Parameter count mismatch.

@Amrinder_Singh
Would you like to provide sample file and a runnable console project? We will check it soon.

var dataToLoadInExcel = new List<BsonDocument>();
foreach (var data in dataList)
{
    var item = new BsonDocument();
    var source = "firstname";
    var columnName = "firstname";
    var dbColumnName = "firstname";
    var columnValue = "SampleUser1";
    item.Add(dbColumnName, columnValue);
    dataToLoadInExcel.Add(item);
}

This is how im preparing the data (list of bson document)

@Amrinder_Singh
Your sample code contains many variables that have not been assigned values. We are unable to use sample code for testing and locating issues. If you could provide a simple and executable console project, it would be very helpful for us to locate the issue.

public async Task<bool> GetExcelWithData(string sheetName, string fileName, int startColumn, int startRow, byte[] buffer)
{
    var inputData = new List<BsonDocument>();
    inputData.Add(new BsonDocument().Add("smaplecolumn", "samplevalue"));
    // To set the Aspose License.
    await SetAsposeLicense();

    Workbook book = new Workbook(new MemoryStream(buffer));
    Worksheet sheet = book.Worksheets[sheetName];

    ImportTableOptions imp = new ImportTableOptions();
    imp.InsertRows = true;
    imp.IsFieldNameShown = true;
    sheet.Name = sheetName;
    sheet.Cells.ImportCustomObjects(inputData, startRow, startColumn, imp);
    book.Worksheets[sheetName].AutoFitColumns();

    //var buffer = await _storageManager.Download(fileName, ContainerType.Report);
    MemoryStream ms = new MemoryStream();
    book.Save(ms, SaveFormat.Xlsx);

    fileDomainResponse.Status = ResponseStatus.Success;
    fileDomainResponse.Content = Convert.ToBase64String(ms.ToArray());
    fileDomainResponse.FileName = fileName;

    return true;
}

@Amrinder_Singh
When calling a method, the parameters passed into the GetExcelWithData method are still unknown. Would you like to provide a runnable program that includes all variables with assigned values? We will check it soon.

I got this problem solved, as you told i was putting wrong information in the method.
Thanks

@Amrinder_Singh,

It is nice to know that your issue is resolved. Please feel free to write us back if you have further queries or comments, we will be happy to assist you soon.

I have aspose.words Table
And in my Document i have placeholder %%Table%%
I want to replace %%Table%% with my aspose.words table how can i ?

@Amrinder_Singh
Thank you for your interest in Aspose.Cells and Words products. I am moving your post to the Aspose.Words Product Family forum for our support staff to help with any technical or functionality related questions you may have.

@Amrinder_Singh You can use IReplacingCallback to achieve this.

ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
    Document doc = (Document)e.MatchNode.Document;

    Node currentNode = e.MatchNode;
    if (e.MatchOffset > 0)
        currentNode = SplitRun((Run)currentNode, e.MatchOffset);

    var builder = new DocumentBuilder(templateDocument);

    builder.MoveTo(currentNode);

    currentNode.ParentNode.InsertAfter(WordsTable, currentNode);
    return ReplaceAction.Skip;
}


private static Run SplitRun(Run run, int position)
{
    Run afterRun = (Run)run.Clone(true);
    run.ParentNode.InsertAfter(afterRun, run);
    afterRun.Text = run.Text.Substring(position);
    run.Text = run.Text.Substring((0), (0) + (position));
    return afterRun;
}

Getting this error - Cannot insert a node of this type at this location

@Amrinder_Singh Please try modifying your code like this:

ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
    Document doc = (Document)e.MatchNode.Document;

    Node currentNode = e.MatchNode;
    if (e.MatchOffset > 0)
        currentNode = SplitRun((Run)currentNode, e.MatchOffset);

    DocumentBuilder builder = new DocumentBuilder(templateDocument);
    builder.MoveTo(currentNode);
    builder.Writeln();

    builder.CurrentParagraph.ParentNode.InsertBefore(WordsTable, builder.CurrentParagraph);
    return ReplaceAction.Skip;
}

If the problem still persist, please attach your template and provide full code that will allow us to reproduce the problem on our side.