Copy link to clipboard
Copied
Hi,
I would like to write the data from Photoshop into Excel template. Excel template having the head line (see below snap shot)
 
The task is to write the data from 2nd row. For that I am using the following code.
Copy link to clipboard
Copied
When you open for write, that deletes whatever is already in the file. You can open for append, or better yet- open the old file, copy the header, write it into a new file, and then write your data. You can save and swap old and new when you finish.
Copy link to clipboard
Copied
@Lumigraphics, I am tried, but the heading is not copied properly, instead of heading content I get junk characters.
Copy link to clipboard
Copied
I only have limited experience with writing to text files, so perhaps something like:
var rep = File.openDialog("Please choose the file");
var os = $.os.toLowerCase().indexOf("mac") >= 0 ? "mac" : "windows";
if (os === "mac") {
repLF = "Unix";
} else {
repLF = "Windows";
}
rep.encoding = "UTF-8";
rep.lineFeed = repLF;
// r = read mode | w = write mode | a = append | e = edit
rep.open("r");
var headerRow = rep.readln(1);
rep.close(); // not sure if needed, seems to work OK with or without
rep.open("w");
rep.writeln(headerRow);
var imageNm =["1", "2","3"];
for(var x=0; x<imageNm.length-1; x++){
rep.write("Asuvath"+"\t"+"smartObjPathFnl[x]"+"\t"+"imageNm[x]"+"\t"+"imgSize[x]"+"\t"+"imgRes[x]"+"\n");
}
rep.close(); // not sure on the necessity to close or not?
Copy link to clipboard
Copied
@Stephen_A_Marsh Thanks for checking, but still I am not get expected result. Can you please check and advise.
Copy link to clipboard
Copied
It would help if you gave the forum something to go on!
Copy link to clipboard
Copied
Hi @Stephen_A_Marsh ,
Sure. I used the below code.
I herewith attached Template excel for your reference.
Thanks
Copy link to clipboard
Copied
For one thing, you need to close the file before reopening it.
Are these CSV or tab-delimited? You realize that Bridge cannot write XLSX files?
Copy link to clipboard
Copied
Okey, I tried, but the result it same. Tab delimited. Yes, I aware on that, thats the reason I am using XLS instead of XLSX.
Thanks
Copy link to clipboard
Copied
You can't use XLS format either. That's why your first line is mangled. ONLY plain text (CSV/tab) files will work.