Use common diaglog to get the file path
txtDir := cduCDMgmt.OpenFile('Select File','',4,'*.csv,0);
Use Record Table to store the file info
RecFile.SETRANGE(Path, GetFolderDir(txtDir));
RecFile.SETFILTER(Name, GetFileName(txtDir));
Use Excel Buffer table to store and read the data
//to get the txtFileName use COPYSTR function in RecFile.Name //sample txtFileName := COPYSTR(RecFile.Name, 1, 5)
//to get the txtSheetName use COPYSTR in RecFile.Name
recExcelBuffer.OpenBook(txtFileName, txtSheetName);
recExcelBuffer.ReadSheet();
My file is a .txt file but the values are separated by ;
If I open it with Excel I get the choice for a separator symbol and then it splits up in columns.
If I use your code I get the complete file in cell A1. Is there a way to set the separator character before opening the file or reading the sheet.
Comments
Try these:
Use common diaglog to get the file path
txtDir := cduCDMgmt.OpenFile('Select File','',4,'*.csv,0);
Use Record Table to store the file info
RecFile.SETRANGE(Path, GetFolderDir(txtDir));
RecFile.SETFILTER(Name, GetFileName(txtDir));
Use Excel Buffer table to store and read the data
//to get the txtFileName use COPYSTR function in RecFile.Name //sample txtFileName := COPYSTR(RecFile.Name, 1, 5)
//to get the txtSheetName use COPYSTR in RecFile.Name
recExcelBuffer.OpenBook(txtFileName, txtSheetName);
recExcelBuffer.ReadSheet();
:thumbsup: rock on!!!
Thanks a lot for reply. The Excelbuffer.Readsheet will update the records in Excel Buffer Tables by Rows & Columns?
Please let me know.
Regards,
Anil
recExcelBuffer.OpenBook(txtFileName, txtSheetName); //opening the csv file using excel to easily read the data ;p
the ExcelBuffer table will be updated and conatins the data on your csv file.
The recExcelBuffer.ReadSheet will Read all records in ExcelBuffer table.
Once again Thanks for the reply. Is there any way to get the Name of the sheet?
Please advise.
The sheet name is the csv file name itself, try to open ur csv file then you will see the sheet name.
Use COPYSTR function to remove the file extension then you can get the sheetname.
:thumbsup: psycholesterol
If I open it with Excel I get the choice for a separator symbol and then it splits up in columns.
If I use your code I get the complete file in cell A1. Is there a way to set the separator character before opening the file or reading the sheet.
The case is solved so thank you for your time.
I'm going to post my solution.