Page 2 of 3

Re: How do I convert CSV = > Excel in Alaska?

Posted: Thu May 14, 2020 7:01 am
by Tom
There must be a way to get you through. I will talk to the guys who run the forum now (I initiated it years ago) and let you know.

Re: How do I convert CSV = > Excel in Alaska?

Posted: Thu May 14, 2020 8:15 am
by rdonnay
Roger, c'mon. It's sooooo much funnier to struggle with strange code from anywhere and for different languages than to just open a damned CSV file with Excel and save it afterwards. 8-)
"There are 2 kinds of people in this world, those with loaded guns, and those who dig. You dig!" - Clint Eastwood (The Good, The Bad and The Ugly)

"If your'e gonna shoot, shoot. Don't talk." - Eli Wallach (The Good, The Bad and The Ugly)

Re: How do I convert CSV = > Excel in Alaska?

Posted: Thu May 14, 2020 8:44 am
by Tom
:lol:

Re: How do I convert CSV = > Excel in Alaska?

Posted: Thu May 14, 2020 8:59 am
by Tom
Hi, Eugene.

If you give me a mail adress via PN, I will give it to the guys who run the forum and they will put it on a whitelist, okay?

Re: How do I convert CSV = > Excel in Alaska?

Posted: Thu May 14, 2020 7:15 pm
by Eugene Lutsenko
Gut. Vielen Dank! Ich habe dir in PM geschrieben

Re: How do I convert CSV = > Excel in Alaska?

Posted: Thu May 14, 2020 9:40 pm
by Eugene Lutsenko
Roger!

Thank you very much! I tried using the function you gave me. What can I say? It converts a CSV file to an XLS file. However, in the Excel file, data from the CSV file is placed in one column, and there are 8 of them. if you enter this CSV file in Excel using Excel itself as text data, then you can create a separator in the dialog. Is it possible to set the separator in your function as a function parameter? And more. The function works very slowly. Files attached

Re: How do I convert CSV = > Excel in Alaska?

Posted: Fri May 15, 2020 12:28 am
by skiman
Hi Eugene,

Don't forget you need to have Excel on your PC to use the activex. This isn't 'universal'.

If this isn't a problem, you can load the csv into an array, and then save it to XLS. If you use 'blocks' of data it will be much faster. If this can help you, I can send you some code as a sample.

You can split the array in blocks of 500 lines, and then send a block to Excel. I tested on this some years ago, and this seems to be the fasted way.

That external lib claims to be very fast, I never used it. Most of my customers have Excel on their system.

Re: How do I convert CSV = > Excel in Alaska?

Posted: Fri May 15, 2020 6:24 am
by Eugene Lutsenko
Hi, Chris!

Of course, the implementation of your function is of interest to me. I also used blocks in Excel, but for converting xls=>dbf. This really accelerated processing very much. Converting csv=>xls takes a long time if the csv file is large. And if it is large, you can't put it (all of it) in the array. And if it is small, then it should be placed in the array, and so it works normally. It turns out that it is necessary to convert the file. We will assume that Excel is available on all computers, and if it is not-then a reasonable message should be issued to the user.

Re: How do I convert CSV = > Excel in Alaska?

Posted: Sun May 17, 2020 10:34 am
by rdonnay
We will assume that Excel is available on all computers, and if it is not-then a reasonable message should be issued to the user.
This is from DC_Array2Excel(). It shows how to test for Excel installed.

Code: Select all

  oExcel := CreateObject("Excel.Application")
  IF Empty( oExcel )
    IF lCSVFallBack
      DCMSGBOX 'Excel is not installed. Create CSV file instead?' YESNO TO lStatus
      IF lStatus
        RETURN DC_Array2CSV(cExcelFile,aData)
      ELSE
        RETURN .f.
      ENDIF
    ELSE
      DC_WinAlert( "Excel is not installed" )
    ENDIF
    RETURN .f.
  ENDIF

Re: How do I convert CSV = > Excel in Alaska?

Posted: Sun May 17, 2020 10:55 am
by rdonnay
However, in the Excel file, data from the CSV file is placed in one column, and there are 8 of them.
The oExcel:Workbooks:Open() method is not recognizing that you have comma-delimited data in your CSV file. By default it probably expected TAB delimiters.

Change your open method call to this:

Code: Select all

oBook := oExcel:Workbooks:Open(cCsvFile,,,2)