Hi all,
I got some problems when I try to read my Excel file as below:
1. It skipped the null cells, it only read data at the cells having value. For example in my case, after reading cell 2 at row 2, it jumped to cell 14.
2. It showed the error message "The given key '3' was not present in the dictionary." at cell 15
You can see my code, the Excel file I used, and the result in below
My code
@page "/testpage"
@using Telerik.Documents.SpreadsheetStreaming;
<div>
@((MarkupString)(str.ToString()))
</div>
@code {
private StringBuilder str = new StringBuilder();
protected override void OnInitialized()
{
str = ReadData();
}
private StringBuilder ReadData()
{
try
{
string filename = ".\\Template.xlsx";
using (FileStream fs = new FileStream(filename, FileMode.Open))
{
using (IWorkbookImporter workBookImporter = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, fs))
{
foreach (IWorksheetImporter worksheetImporter in workBookImporter.WorksheetImporters)
{
foreach (IRowImporter rowImporter in worksheetImporter.Rows)
{
foreach (ICellImporter cell in rowImporter.Cells)
{
if(cell.Value!= null)
{
str.Append(cell.Value.ToString());
}
else
{
str.Append("NULL");
}
str.Append(",");
}
str.Append("<br/>");
}
}
}
}
return str;
}
catch(Exception ex)
{
str.Append("<br/>");
str.Append(ex.Message);
return str;
}
}
}
My Excel file as a picture below, I also attached my Excel in the question (Template.rar)
The result when I run
Everyone who know how to fix it, please help me.
Thank you
Hi Chinh,
I see that the product of the ticket is Upload for Blazor, however, it looks like the scenario targets the Document Processing libraries.
I have changed the product, so my colleagues from the Document Processing team can revise the case. For that purpose, can you please send the Excel file in question, so they can test reading it? This will help speed up the case resolving process.
Thank you in advance!
Thank you Nadezhda, I attached the excel file I used in this question, please see it.
It is an urgent case, I hope your team can help me.