Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I have created a function that returns a
datatable
from a
workbook
.
public async Task<DataTable> GetDataTableFromTabRowColumn(string sheetName, int startRow, int endRow, int startCol, int endCol)
var task = new Task(() =>
DataTable dt = new DataTable();
Workbook wb = new Workbook(FilePath); // error line
Worksheet worksheet = wb.Worksheets[sheetName];
dt = worksheet.Cells.ExportDataTable(startRow - 1, startCol - 1, (endRow - startRow + 1), (endCol - startCol + 1), options);
task.Start();
await task;
return dt;
It was running fine. When I made the function async, it's showing error:
Aspose.Cells.CellsException: 'You are using an evaluation copy and
have opened files exceeding limitation.'
I am using licensed Aspose. Please help
–
–
–
Aspose.Cells tries to find the license in the following locations:
Explicit path The folder that contains Aspose.Cells.dll
The folder that contains the assembly that called Aspose.Cells.dll
The folderthat contains the entry assembly (your .exe)
An embedded resource inthe assembly that called Aspose.Cells.dll
//Instantiate an instance of license and set the license file through its path
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Cells.lic");
//Instantiate an instance of license and set the license through a stream
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(myStream);
Before blaming it on Aspose, lets fix the async approach.
public async Task<DataTable> GetDataTableFromTabRowColumn(string sheetName, int startRow, int endRow, int startCol, int endCol)
var task = Task.Run(() =>
Workbook wb = new Workbook(FilePath); // error line
Worksheet worksheet = wb.Worksheets[sheetName];
DataTable dt = worksheet.Cells.ExportDataTable(startRow - 1, startCol - 1, (endRow - startRow + 1), (endCol - startCol + 1), options);
return dt;
return await task;
Note that dt
can and should be local like this.
Remove the private DataTable dt = null;
line because it could cover up an error.
When this still gives an error I would look at Aspsose again.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.