Import CSV/TXT data
Imports data from remote CSV/TXT files into the spreadsheet.
This macro is operational only with the desktop versions of the ONLYOFFICE editors.
(function()
{
function LoadFile() {
$.ajax({
url: 'your url',
dataType: 'text',
}).done(successFunction);
}
function successFunction(data) {
let arrAllRows = data.split(/\r?\n|\r/);
let worksheet = Api.GetActiveSheet();
//reference point
let i = 1;
let j = 1;
for (let singleRow = 0; singleRow < arrAllRows.length; singleRow++) {
let rowCells = arrAllRows[singleRow].split(',');
for (let rowCell = 0; rowCell < rowCells.length; rowCell++) {
worksheet.GetCells(i,j).SetValue(rowCells[rowCell]);
j = j + 1;
}
i = i + 1;
j = 1;
}
}
LoadFile();
let reload = setInterval(function(){
Api.asc_calculate(Asc.c_oAscCalculateType.All);
});
})();
Methods used: GetActiveSheet, GetCells, SetValue