I'm trying to create a .txt file using the excel javascript API and I have no idea how to get this done (I'm new to coding)
The text I want to be inside the .txt file is already in a variable named "output".
This is my try:
function saveTxt(txt) {
var name = context.workbook.name
var Path = Office.context.document.url.slice(0,-name.length)
var saveFile = new File(Path + "data.txt");
if (saveFile.exists){
saveFile.remove();
}
saveFile.encoding = "UTF8";
saveFile.open("e", "TEXT", "????");
saveFile.writeln(txt);
saveFile.close();
}
saveTxt(output)
When I run the code I get a "function expected" error. Would be nice to count with your help to solve that!
Btw, I don't know if it's relevant, but I'm coding directly in the ScriptLab excel add-in
Thanks!