Page 1 of 1
Import CSV-File in a Excel-File
Posted: Tue Jan 12, 2016 8:37 pm
by JuergenStr
Hello,
1.
I just test this component (yet) with the demo 5.20.67a.
I am searching for a Excel components which CSV files can be imported into an Excel file.
I have indeed found the function ImportCSV () in this forum, but do not know how this function is to be applied. In my Delphi this function is not recognized. When I use the Unit "XLSImportCSV" under "uses" can not find my Delphi this Unit.
A small example of the CSV import in an Excel file would help me a lot!
Many Thanks!
Edit:
After I found that you have to integrate the Unit XLSImportCSV5, can call the function.
The following function call does but not work:
Code: Select all
ImportCSV(XLSReadWriteII5.TXLSReadWriteII5, 0, 0, 'c:\_Programmierung\installierte_Komponeten\Excel_Axolot\AIDA-Export.csv', ';', false);
Error: There is no overloaded version of 'Import CSV' that can be called with these arguments
2.
Furthermore i'm searching a component which an Excel file a column set as date format. Is this with XLSReadWritwII 5 possible?
Many greetings Jürgen
Re: Import CSV-File in a Excel-File
Posted: Wed Jan 13, 2016 11:08 am
by larsa
Hello
1. Here is a description of ImportCSV:
Code: Select all
//* This routine will import a text (CSV) file into a worksheet. Any existing cells on the worksheet will be overwritten.
//* Correct value for decimal separator is detected automatically. See alse ~[link ImportCSVAuto]
//* ~param XLS The target XLSReadWriteII object.
//* ~param SheetIndex The index to the worksheet where the file will be imported to.
//* ~param Col Left column where the imported data will be written.
//* ~param Row Top row where the imported data will be written.
//* ~param Filename The name of the text file that shall be imported.
//* ~param SepChar Separator character for the fields (cells) in the source file.
//* ~param HasQuoteChar Set this to True if strings in the source file are quoted.
//* ~result The number of cells that where imported.
function ImportCSV(XLS: TXLSReadWriteII5; SheetIndex,Col,Row: integer; Filename: AxUCString; SepChar: AxUCChar; HasQuoteChar: boolean): boolean; overload;
function ImportCSV(XLS: TXLSReadWriteII5; SheetIndex,Col,Row: integer; List: TStrings; SepChar: AxUCChar; HasQuoteChar: boolean): boolean; overload;
//* This routine will import a text (CSV) file into a worksheet. Any existing cells on the worksheet will be overwritten.
//* The routine will try to detect correct values for separator character, quote character and decimal separator. See alse ~[link ImportCSV]
//* ~param XLS The target XLSReadWriteII object.
//* ~param SheetIndex The index to the worksheet where the file will be imported to.
//* ~param Col Left column where the imported data will be written.
//* ~param Row Top row where the imported data will be written.
//* ~param Filename The name of the text file that shall be imported.
//* ~result The number of cells that where imported.
function ImportCSVAuto(XLS: TXLSReadWriteII5; SheetIndex,Col,Row: integer; Filename: AxUCString): boolean;
2. You can use date/time values if they are written in the same format as defined in the system.
Re: Import CSV-File in a Excel-File
Posted: Wed Jan 13, 2016 9:29 pm
by JuergenStr
Hello,
thx, the CSV import now works.
The datatypes (times and dates) are even recognized and already spent properly formatted in Excel!
However, there is a problem with times-Values, when the time is "00:00" in my CSV file.
Then this value is output in Excel as follow (7.Column, 4.Row) = "00.01.1900", instead should "00:00"):
Code: Select all
07.12.2015 10.01.2016 DAY BILL 07:00 16:00 00:30 08:30
08.12.2015 10.01.2016 DAY BILL 07:00 16:00 00:30 08:30
09.12.2015 10.01.2016 DAY BILL 07:00 13:35 00:30 06:05
10.12.2015 10.01.2016 DAY BILL 10:00 16:00 00.01.1900 06:00
11.12.2015 10.01.2016 DAY BILL 07:00 16:00 00:30 08:30
07.12.2015 10.01.2016 DAY BILL 13:45 21:45 00:30 07:30
The CSV-File:
Code: Select all
07.12.2015;10.01.2016;DAY;BILL;07:00;16:00;00:30;08:30
08.12.2015;10.01.2016;DAY;BILL;07:00;16:00;00:30;08:30
09.12.2015;10.01.2016;DAY;BILL;07:00;13:35;00:30;06:05
10.12.2015;10.01.2016;DAY;BILL;10:00;16:00;00:00;06:00
11.12.2015;10.01.2016;DAY;BILL;07:00;16:00;00:30;08:30
07.12.2015;10.01.2016;DAY;BILL;13:45;21:45;00:30;07:30
Can you somehow get around / fix?
Many greetings Jürgen
Re: Import CSV-File in a Excel-File
Posted: Thu Jan 14, 2016 11:29 am
by larsa
Hello
This is fixed in the latest update. Zero date/time values where stored as date values. It's now changed to time values.
Re: Import CSV-File in a Excel-File
Posted: Thu Jan 14, 2016 10:21 pm
by JuergenStr
Hello,
cool. I'll buy the XLSReadWriteII-Component coming soon.