Alaska Software Inc. - Create excel file
Username: Password:
AuthorTopic: Create excel file
Salvatore Megna Create excel file
on Fri, 10 Nov 2017 11:09:15 +0100
Goodmorning
how do you create excel files and how do you read excel files?

I before used odbc but with new windows update is not usable and with my 
new procedure is very slow

I attached my new procedure

Best regards


excel.prg
Edgar Borger Re: Create excel file
on Fri, 10 Nov 2017 12:12:14 -0200
Hello Salvatore,

to read I use something like this :

         oExcel := CreateObject("Excel.Application")
         oWorkbooks := oExcel:workbooks
         oBook  := oWorkbooks:open( cArq )                             <========== cArq = file name
         oSheet := oBook:ActiveSheet
         oBook:workSheets(1):usedRange:Select
         nRows  := oBook:workSheets(1):usedRange:Rows:Count
         nCols  := oBook:workSheets(1):usedRange:Columns:Count
         oRange := oSheet:Range("A1", chr(64+nCols) + strzero(nRows,4) )
         aValue := oRange:value

aValue contains array of the spreadsheet



to create a new one :

     fErase( XLS )
     oExcel := CreateObject("Excel.Application")
     oWorkbooks := oExcel:workbooks
     oBook  := oExcel:workbooks:Add()
     oSheet := oBook:ActiveSheet
     oExcel:DisplayAlerts := .f.
     oExcel:visible       := .f.

     oRange := oSheet:Range("A1", chr(64+len(aExcel[1])) + strzero(len(aExcel),4) )
     oRange:font:name := 'Courier New'
     oRange:font:size := 10
     oRange:value     := aExcel
     for i = 2 to len(aExcel[1])
         oSheet:Columns(i):Autofit()
     next
     oBook:SaveAs(XLS)

     oSheet:destroy()
     oBook:close()
     oBook:destroy()

      Quit Excel
     oExcel:Quit()
     oExcel:Destroy()


Regards,
Edgar


Em 10/11/2017 08:09, Salvatore Megna escreveu:
> Goodmorning
> how do you create excel files and how do you read excel files?
> 
> I before used odbc but with new windows update is not usable and with my new procedure is very slow
> 
> I attached my new procedure
> 
> Best regards
> 
> 


Edgar Borger
Softsupply Informatica Ltda.
Rua Alagoas, 48
Sao Paulo, SP
01242-000
Tel   : (5511) 3159-1997
Email : softsupply@terra.com.br
Slavko SlavicRe: Create excel file
on Wed, 14 Feb 2018 00:10:04 +0100
Thanks Edgar

Edgar Borger wrote:
> Hello Salvatore,
>
> to read I use something like this :
>
>         oExcel := CreateObject("Excel.Application")
>         oWorkbooks := oExcel:workbooks
>         oBook  := oWorkbooks:open( cArq )
> <========== cArq = file name
>         oSheet := oBook:ActiveSheet
>         oBook:workSheets(1):usedRange:Select
>         nRows  := oBook:workSheets(1):usedRange:Rows:Count
>         nCols  := oBook:workSheets(1):usedRange:Columns:Count
>         oRange := oSheet:Range("A1", chr(64+nCols) + strzero(nRows,4) )
>         aValue := oRange:value
>
> aValue contains array of the spreadsheet
>
>
>
> to create a new one :
>
>     fErase( XLS )
>     oExcel := CreateObject("Excel.Application")
>     oWorkbooks := oExcel:workbooks
>     oBook  := oExcel:workbooks:Add()
>     oSheet := oBook:ActiveSheet
>     oExcel:DisplayAlerts := .f.
>     oExcel:visible       := .f.
>
>     oRange := oSheet:Range("A1", chr(64+len(aExcel[1])) +
> strzero(len(aExcel),4) )
>     oRange:font:name := 'Courier New'
>     oRange:font:size := 10
>     oRange:value     := aExcel
>     for i = 2 to len(aExcel[1])
>         oSheet:Columns(i):Autofit()
>     next
>     oBook:SaveAs(XLS)
>
>     oSheet:destroy()
>     oBook:close()
>     oBook:destroy()
>
>      Quit Excel
>     oExcel:Quit()
>     oExcel:Destroy()
>
>
> Regards,
> Edgar
>
>
> Em 10/11/2017 08:09, Salvatore Megna escreveu:
>> Goodmorning
>> how do you create excel files and how do you read excel files?
>>
>> I before used odbc but with new windows update is not usable and with
>> my new procedure is very slow
>>
>> I attached my new procedure
>>
>> Best regards
>>
>>
>
>


slavko_slavic.vcf