How do I convert CSV = > Excel in Alaska?

This forum is for eXpress++ general support.
Message
Author
User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

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

#11 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

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

#12 Post 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)
The eXpress train is coming - and it has more cars.

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

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

#13 Post by Tom »

:lol:
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

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

#14 Post 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?
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

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

#15 Post by Eugene Lutsenko »

Gut. Vielen Dank! Ich habe dir in PM geschrieben

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

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

#16 Post 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
Attachments
1.zip
(15.98 KiB) Downloaded 553 times

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

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

#17 Post 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.
Best regards,

Chris.
www.aboservice.be

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

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

#18 Post 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.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

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

#19 Post 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
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

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

#20 Post 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)
The eXpress train is coming - and it has more cars.

Post Reply