Unanswered question

Writing the run time data/content to excel file

Hi All, I'm using the bewlo code to write the data to text file, how can I write the data to excel file...can some one help me in this..

var lock = new java.util.concurrent.locks.ReentrantLock();
var WFE_CreateSavedSearch = context.variableManager.getValue("WFE_CreateSavedSearch");

if (WFE_CreateSavedSearch==null)
{
context.fail("Variable 'WFE_CreateSavedSearch' not found");
}
function writeFile(text)
{
lock.lock();

var writer = new java.io.FileWriter("c:\\log.txt",true);
writer.write(WFE_CreateSavedSearch+";"+context.currentVU.id+";"+text);
writer.write("\r\n");
writer.close();
lock.unlock();
}


var WFE_CreateSavedSearch = context.variableManager.getValue("WFE_CreateSavedSearch");

if (WFE_CreateSavedSearch==null)

{

context.fail("Variable 'WFE_CreateSavedSearch' not found");

}
writeFile(WFE_CreateSavedSearch+";was the value from my test");

Anonymous
Anonymous

Anonymous

Level
0
17 / 100
points

Answers

christophe M.
christophe M.

christophe M.

Level
4
5000 / 5000
points
Team

Hi,

I don't know exactly what is your problem with the attached code. Trying to give some answers anyway:

It looks like you tried to write a CSV file manually by separating the values by a semi-column ';'.

If this is the CSV value separator of your platform then it's OK. IT could be ','. Also, it can me more convenient to name the file "log.csv" so that you can open it faster with Excel.

The tricky part when doing it manually is the handling of special characters like the separator in your value. If your values can contain a separator value, then you should find a CSV writer utility class that would handle the escaping part. A Java library should be added to the following folder to be used by a Javascript: <neoload-project>/lib/jslib/

Anonymous
Anonymous

Anonymous

Level
0
17 / 100
points

Hi ,

Using the above code I can write the data to txt file. For writing the runtime data/dynamic values returend by servers to an excel file do you have any sample code ?

I'm not able to write to excel using the same code. I need to write to diffret columns and rows..

Thanks for your help!