I'm working on some code to export a DataTable to Excel, and I'm trying to make it as fast as possible. Right now, I'm looping through each row and each column for each row (nested for loops). When I've got a large DataTable, this process can take some time. Can I assign a range of cells to an array in Javascript instead of looping through the columns?
Here's a sample of what I'm doing.
for (var rowIndex = 0; rowIndex < json.worksheets.raw.rows.count; rowIndex++) {
row = rowIndex + 2;
for (var columnIndex = 0; columnIndex < json.worksheets.raw.rows.values[rowIndex].length; columnIndex++) {
column = columnIndex + 1
XLWorksheet.Cells(row, column) = json.worksheets.raw.rows.values[rowIndex][columnIndex];
}
}
I get the JSON data using an AJAX call to a web service in my ASP.NET project.