I have notes documents that I would like to export to excel, depending on a date range.
No problem for the text fields , but how do I 'grab' the text out of a notes rtf to export it to excel.
I may not use POI 4 xpages , so I need another solution
To export the data to excel I use :
var exCon = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
output += "<tr>";
output += "<td>" + viewEnt.getColumnValues()[0]; + "</td>";
//etc for the other columns
response.setContentType("application/vnd.ms-excel");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition","attachment; filename=export.xls");
writer.write("<table>");
writer.write("<thead><tr>");
writer.write("<td><b>First column name</b></td>");
//etc for the other columns
writer.write("</tr></thead>");
writer.write(output);
writer.write("</table>");
writer.endDocument();
That is working.
In column 8 I have the unid, so to get the rtf I tried :
var unid=viewEnt.getColumnValues()[8]
var doc:NotesDocument = database.getDocumentByUNID(unid);
var rtf = doc.getFirstItem("crm_doc").toString();
But this returns 'crm_doc' instead of the contents of crm_doc ....
toString converts the item to a String, not the content. Try getText instead.
Related
I have an Excel (xlsx) file that has 3 columns of data that is set to replace said data in a Photoshop file (PSD), to do so I need to load it into Photoshop in a txt format, encoded to ANSI, so that Photoshop can read that file, and export it a bunch of times each time with the next row's properties.
However my Excel file has some Hebrew text, that is lost when encoding to ANSI, I tried other encodings but Photoshop doesn't accept them, how can I still feed Photoshop with the Hebrew data? (It's a lot of photos so I can't do it manually one by one)
This works for me: I've got a simple text file, with some Hebrew text on it.
And from Photoshop:
var myfile = "D:\\temp\\hebrew.txt"; // change this
var text = read_it(myfile);
alert(text);
// השועל החום המהיר קופץ מעל הכלב העצלן.
// function READ IT (filename with path) :returns string
// ----------------------------------------------------------------
function read_it(afilepath)
{
var theFile = new File(afilepath);
//read in file
var words = ""; // text collection string
var theTextFile = new File(theFile);
theTextFile.open('r');
while(!theTextFile.eof)
{
var line = theTextFile.readln();
if (line != null && line.length >0)
{
words += line + "\n";
}
}
theTextFile.close();
// return string
return words;
}
In a google sheet, I managed to filter file name and file type and list all the particular files needed from a google drive folder based on the conditions into a spreadsheet. I am having an issue to convert the excel files into spreadsheet because I'm opening the selected files using "SpreadsheetApp.openById(id)" in another function() to get the data range from the specific files.
Based on the requirement set, I was been asked to convert the excel files into spreadsheet before getting the range data and export those data into another sheet.
Below are the codes that i created to list the file name and file type, so i believe that the file conversion method might need to be implemented here as well because it involves the file filtering process and these are the files need to be converted later on. Please correct me if I am wrong.
function getChildFiles(parentName, parent, sheet) {
var fileIter = parent.searchFiles("title contains 'completed'and title contains 'Verification
Visit Direct Suppliers'and mimeType='application/vnd.openxmlformats-
officedocument.spreadsheetml.sheet'");
var output = [];
var now = new Date();
var date = new Date();
var copy = new Date(date);
while (fileIter.hasNext()) {
var file = fileIter.next();
var fileName = file.getName();
var fileType = file.getMimeType();
var filecreatedate = file.getDateCreated();
var fileUpdate = file.getLastUpdated()
var path = parentName + ' |--> ' + fileName;
var fileID = file.getId();
var Url = 'https://drive.google.com/open?id=' + fileID;
output.push([fileID, fileName, path, Url,filecreatedate,fileUpdate,copy]);
Logger.log(fileType);}
if (output.length) {
var last_row = sheet.getLastRow();
sheet.getRange(last_row + 1, 1, output.length, 7).setValues(output);
SpreadsheetApp.flush();}
var childFolders = parent.getFolders();
while (childFolders.hasNext()) {
var childFolder = childFolders.next();
var childFolderName = childFolder.getName();
getChildFiles( parentName + ' |--> ' + childFolderName, childFolder, sheet);}}
So I'm trying to implement the file conversion method from excel file to spreadsheet, so that i can extract data from the excel file after the file successfully converted to spreadsheet.
I have been attempting to create a Telegram bot that searches a preexisting database and outputs information based on search query, essentially I want the bot to just receive a text via Telegram that contains an invoice number and output all relevant information regarding that order (The entire row of information).
Since I am dealing with invoice numbers and tracking numbers, sometimes the bot is exporting incorrect information given the current script is not matching exact text or a specific column.
For instance, rather than searching and finding invoice number it picks up a partial match of tracking number and outputs the wrong information.
I would like to set it up to search a specific column, ie. Column 3 - "Invoice #" and then output the entire row of information.
Thanks in advance!
I have been working in Google App Script:
var token = "";
var telegramUrl = "https://api.telegram.org/bot" + token;
var webAppUrl = "";
var ssId = "";
function getMe() {
var url = telegramUrl + "/getMe";
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
function setWebhook() {
var url = telegramUrl + "/setWebhook?url=" + webAppUrl;
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
function sendText(id,text) {
var url = telegramUrl + "/sendMessage?chat_id=" + id + "&text=" + text;
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
function doGet(e) {
return HtmlService.createHtmlOutput("Hi there");
}
function doPost(e) {
var data = JSON.parse(e.postData.contents);
var text = data.message.text;
var id = data.message.chat.id;
var name = data.message.chat.first_name + " " + data.message.chat.last_name;
var answer = "Hi " + name + ", please enter invoice number.";
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Orders");
var search_string = text
var textFinder = sheet.createTextFinder(search_string)
var search_row = textFinder.findNext().getRow();
var value = SpreadsheetApp.getActiveSheet().getRange("F"+search_row).getValues();
var value_a = SpreadsheetApp.getActiveSheet().getRange("G"+search_row).getValues();
sendText(id,value+" "+ value_a)
}
You want to find rows where the content in column 3 is exactly equal to your variable "text"
Modify your function doPost as following:
function doPost(e) {
var data = JSON.parse(e.postData.contents);
var text = data.message.text;
var id = data.message.chat.id;
var name = data.message.chat.first_name + " " + data.message.chat.last_name;
var answer = "Hi " + name + ", please enter invoice number.";
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Orders");
var range = sheet.getRange(1,1, sheet.getLastRow(), sheet.getLastColumn());
var values = range.getValues();
for (var i=0; i< values.length; i++){
var column3Value = values[i][2];
if(column3Value == text){
var rowValues = values[i].toString();
sendText(id,rowValues)
}
}
}
Explanations
The for loop iterates through all rows and compares the values in column 3 (array element[2] against the value of text
The operator == makes sure that only exact matches are found (indexOf() would also retrieve partial matches)
In case a match is found, the values from the whole row are converted to a comma separated string with toString() (You can procced the values differntly if desired)
Every row with a match will be sent to the function sendText() (you could alternatively push all rows with matches into an array / string and call sendText() only once, after exiting the for loop
I hope this answer helps you to solve your problem and adapt the provided code snippet to your needs!
I would look for a specific column where the order number is stored.
I`m not sure if it is the best way from performance side, but I think it should work.
function orderInformation(orderNumber){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Orders");
//Gets last row in Orders sheet
var lastRow = sheet.getLastRow();
//Here you can change column where is order number stored
var orderNumberRange = sheet.getRange("A1:A" + lastRow);
//Gets all order number values
var orderNumbers = orderNumberRange.getValues();
//You can use indexOf to find which row has information about requested order
var orderLocation = orderNumbers.indexOf(orderNumber);
//Now get row with order data, lets suppose that your order information is from column A to Z
var orderData = sheet.getRange("A" + (orderLocation + 1) + ":Z" + (orderLocation + 1)).getValues();
//Now you have all data in array, where you can loop through and generate response text for a customer.
}
Sorry, I have not tested it, at the moment I don`t have time to make a test sheet, but this is the way I would do it and I think it should work.
I will test it maybe later when I will be able to make a test sheet.
I load my excel to gridview in c# Winform and I use Excel.4.5 for reading.My value in my excel row cell 7885266361743930.But it comes to my gridview like this => 7,88526636174393E+15 in normal what I waiting
is => 7885266361743930 like in my excel :)
This is my method to read the excel :
var stream = File.Open(openFileDialog1.InitialDirectory + openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
var excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
I have 3 multi-value fields and I have already inserted values in them. All of the fields are Text type, edible. What I'm trying to do is that I want to add functionality in xpages, so that I can add new values to those fields.
Here's what I got so far:
The code that triggers on the save button:
var statuss = document1.getItemValue("statuss");
var stat_vec:java.util.Vector = document1.getItemValue("statuss_update");
stat_vec.add(statuss);
document1.replaceItemValue("statuss_update", stat_vec);
var vards = session.getEffectiveUserName();
var vards_vec:java.util.Vector = document1.getItemValue("name_update");
vards_vec.add(vards);
document1.replaceItemValue("name_update", vards_vec);
var laiks = session.createDateTime("Today");
var laiks_vec:java.util.Vector = document1.getItemValue("time_update");
laiks_vec.add(laiks);
document1.replaceItemValue("time_update", laiks_vec);
document1.save();
The code that I have atteched to the computedField, where the values are displayed from the 3 multi value fields + it refreshes when I insert new values:
var x = document1.getItemValue("statuss_update");
var y = document1.getItemValue("name_update");
var z = document1.getItemValue("time_update");
var html = "<head><link rel=\"stylesheet\" type = \"text/css\" href=\"test.css\"></head><table id=\"tabula\">";
for (i = 0 ; i < x.size()-1; i++){
html= html + "<tr><td>" + x[i] + "</td><td>" + y[i] + "</td><td>" +z[i] + "</td></tr>";
}
html = html + "</table>";
I can insert the values and they get displayed in the HTML table but the problem is with saving the edits. Whenever I try to save the document (I have a save button that has save document event attached to it) I get the error:
Could not save the document 1B06 NotesException: Unknown or
unsupported object type in Vector
As far as I understand I'm trying to savesomething in a field, where the values type is not supported. Can anyone give me a hint what am I doing wrong or where to look for the problem? Been stuck with this for a pretty long time.
Is it this part?
var statuss = document1.getItemValue("statuss");
var stat_vec:java.util.Vector = document1.getItemValue("statuss_update");
stat_vec.add(statuss);
It looks like you're getting the statuss item's values (potentially a Vector??) and adding it to the Vector for statuss_update. If it's definitely just one value, getItemValueString() would work better.
I'm nnot sure if this is right, but you mention all fields are Text type, but it looks like you're passing a DateTime to the third one.
It might be worth analysing the contents of the Vectors before it's doing the save, just to make sure they contain what you expect.