T O P I C R E V I E W |
gali01 |
Posted - 05/18/2011 : 1:54:34 PM Origin Ver. 8.1 SR2 Operating System: Vista business
I'm trying to export all the data into ASCII files I got the data by I'm having problem with the notes in each workbook
The current code is
// choose directory fdlog.openpath(B); // Loop over all books doc -e W { // loop over all sheets doc -e LW { // put sheet name into variable sheet$=layer.name$; if (%(sheet$) == "Note") { save -n %H %B%H-%(sheet$).txt } else { save -w %H %B%H-%(sheet$).txt } } }
I think that I need to open a window from the note sheet in the workbook in order for the save -n to work. but how ? And if I use the save -w on that sheet I do get a file but the experiment data is truncated (the ~6k limit per cell ?) |
9 L A T E S T R E P L I E S (Newest First) |
JoSummers |
Posted - 06/14/2011 : 06:29:56 AM Will this work for the Windows 7 operating system? I've recently upgraded and wanted to make sure that I don't need to be doing anything different. |
gali01 |
Posted - 05/26/2011 : 02:50:34 AM Great. Thanks So here is the generic form of this routine
int Project_Notes_Export() { string strPath; char NoteFileName[1000]; string strBooksheet;
Worksheet wks; int nRow, nCol; DWORD dwCntrl; //get the user to select a folder strPath = BrowseGetPath(); if( ! strPath.IsEmpty()) { // Loop over all the note pages in the project foreach(Note nte in Project.Notes) { //get the workbook this belongs to if(nte.GetEmbeddingInfo(wks, &nRow, &nCol, &dwCntrl)) { strBooksheet = wks_get_book_sheet_name(wks); } // create the file name sprintf(NoteFileName, "%s%s.txt", strPath , strBooksheet ); //create a file stdioFile ff(NoteFileName, file::modeCreate|file::modeReadWrite); //write the note's text to the file ff.WriteString(nte.Text); } } return 0; }
|
Penn |
Posted - 05/25/2011 : 10:35:40 PM Hi,
In Origin C, you can just get the text of the note window, and then write this text to a file by WriteString in stdioFile class. For example (pay attention to the red lines):
int Project_Notes_Export()
{
char NoteFileName[1000];
string strBooksheet;
Window wnd;
Worksheet wks;
int nRow, nCol;
DWORD dwCntrl;
// Loop over all the note pages in the project
foreach(Note nte in Project.Notes)
{
// create the file name
if(nte.GetEmbeddingInfo(wks, &nRow, &nCol, &dwCntrl))
{
strBooksheet = wks_get_book_sheet_name(wks);
}
sprintf(NoteFileName, "%s%s%s", "C:\\ASCII\\" , strBooksheet , ".txt");
//
stdioFile ff(NoteFileName, file::modeCreate|file::modeReadWrite);
ff.WriteString(nte.Text);
}
return 0;
}
Penn |
gali01 |
Posted - 05/25/2011 : 3:43:23 PM OK, so I've got it to do most of what I need by using both LabTalk and OriginC
// choose directory fdlog.openpath(B); // Loop over all books doc -e W { // loop over all sheets doc -e LW { // put sheet name into variable string sheet$=layer.name$; sheet.Remove("/");
if ((%(sheet$) != "Note") && (left(sheet$,5)$ != "Graph") && (left(sheet$,7)$ != "Contour")) { save -w %H %B[%H]%(sheet$).txt }
} }
int Project_Notes_Export() { char NoteFileName[1000]; string strBooksheet; Window wnd;
Worksheet wks; int nRow, nCol; DWORD dwCntrl;
// Loop over all the note pages in the project foreach(Note nte in Project.Notes) { // create the file name if(nte.GetEmbeddingInfo(wks, &nRow, &nCol, &dwCntrl)) { strBooksheet = wks_get_book_sheet_name(wks); } sprintf(NoteFileName, "%s%s%s", "C:\\ASCII\\" , strBooksheet , ".txt"); // show the window nte.SetShow(); // save the note BOOL bOK = nte.SaveToFile(NoteFileName); //get the winodw wnd = nte.GetWindow(); // hide window if(wnd) { wnd.ShowWindow(SW_HIDE); } } return 0; }
The main issue left, is the fact that somehow all the notes windows are left open after it is done |
lizahunk |
Posted - 05/25/2011 : 07:26:31 AM Hi nice discussion |
gali01 |
Posted - 05/24/2011 : 12:32:58 PM OK, I've uploaded the project file I also modified my script a bit
using some Origin C
void set_note_show(string strName = "Notes") { Note note(strName); note.SetShow(); }
// choose directory fdlog.openpath(B); // Loop over all books doc -e W { // loop over all sheets doc -e LW { // put sheet name into variable sheet$=layer.name$; if (%(sheet$) == "Note") { set_note_show(); save -n "Notes" %B%H-%(sheet$).txt; win -cn "Notes"; } else { save -w %H %B%H-%(sheet$).txt } } }
which is good for the first note but the set_note_show function doesn't seem to be working on the following worksheets in the project |
Penn |
Posted - 05/24/2011 : 05:53:12 AM Hi,
Maybe it needs your project file to see what the problem is. Please send your project with your serial number to Origin technical support by following the instruction in this page. Please refer to this post in your email.
Penn |
gali01 |
Posted - 05/24/2011 : 03:19:36 AM Thanks for the quick response
The script executes w/o any error, however I'm not getting the information I need The "note sheet in workbook" is a sheet which contains the test's setup parameters (in what looks like a single cell). It is automatically created by the instrument (fluoremeter) and contains the content of the instrument setup file The setup file is a xml file, but since it has many characters the export function (save -w) is truncating that
I've tried the expASC function in the following
// choose directory fdlog.openpath(B); // Loop over all books doc -e W { // loop over all sheets doc -e LW { // put sheet name into variable sheet$=layer.name$; if (%(sheet$) == "Note") { expASC type:=csv path:=%B%H-%(sheet$)-n } else { save -w %H %B%H-%(sheet$).txt } } }
but the file is empty although the script window output said "Note is exported to C:\ASCII\Try6-Note-n.csv"
|
Penn |
Posted - 05/24/2011 : 02:33:36 AM Hi,
Do you have inserted a note window into a cell? If so, please note that, save -w is used to save the worksheet data to a ASCII file, and the inserted note window cannot be converted to ASCII data here.
Penn |
|
|