Page 1 of 2

Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 8:44 am
by Eugene Lutsenko
Hi, Roger! Hello everybody!

Don't know why the function: DC_WorkArea2Excel() creates a dbf file instead of an Excel file?

Code: Select all

          mNameLangXls = 'LangTransl_' + aISO639_1[j] + '.XLS'
          aFields := { 'TextOrig' }
          DC_WorkArea2Excel(mNameLangXls,,,,aFields)         // Преобразовать БД mNameLangDB в XLS-файл
[/size]

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 9:43 am
by rdonnay
How do you know that it's a DBF file?

Does it have a DBF extension?

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 10:15 am
by Eugene Lutsenko
Yes, we get files with names like LangTransl_en.DBF. Online translator of Excel tables: https://www.onlinedoctranslator.com/translationform does not accept these files.

Most likely, these xls files are not clear where they are written. I didn't find them

Code: Select all

   FOR j=1 TO LEN(aISO639_1)

       IF aISO639_1[j] <> 'ru'
       
          mNameLangDB  = 'LangTr_' + aISO639_1[j]
          mNameLangXls = 'LangTransl_' + aISO639_1[j] + '.XLS'

          aStructure := { { "TextOrig", "C", mLF, 0 } }
          DbCreate((mNameLangDB), aStructure )

          CLoseAll()            // Закрытие всех баз данных с ожиданием завершения операций          
          USE (mNameLangDB) EXCLUSIVE NEW
          SELECT (mNameLangDB)
          
          FOR i=1 TO LEN(aLangRu)
              APPEND BLANK
              REPLACE TextOrig WITH aLangRu[i]
          NEXT
          
          aFields := { 'TextOrig' }
          DC_WorkArea2Excel(mNameLangXls,,,,aFields)         // Преобразовать БД mNameLangDB в XLS-файл

      ENDIF
   NEXT
[/size]

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 11:06 am
by rdonnay
DC_WorkArea2Excel() uses the Excel ActiveX control that is installed on your computer to create the XLS file.

I don't know of any way that it can be told to create a DBF instead of an XLS.

I will need a small sample program from you that demonstrates this problem.

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 11:09 am
by Eugene Lutsenko
I made different short names for dbf and xls files and saw that there are no xls files anywhere. the impression is that they are not generated and not recorded. Although the function's progress bar shows that they are being formed.

Example do. I'll send it soon

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 12:37 pm
by rdonnay
Your sample correctly creates an XLS file on my computer.

My guess is that you have Excel configured in a way that it creates a DBF.

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 12:48 pm
by Eugene Lutsenko
rdonnay wrote:Your sample correctly creates an XLS file on my computer.

My guess is that you have Excel configured in a way that it creates a DBF.
May be. I configured Excel to OPEN dbf files. And he can be using this setting to create them? I'll check it out

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 1:02 pm
by Eugene Lutsenko
Changed this setting to a different program. It didn't change anything. I also have two versions of Excel on my computer: 2003 and 2010.

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 1:49 pm
by rdonnay
Attached is the XLS file that was created.

This is a mystery to me.
I can't find anything on a Google search to explain this, except for this: https://docs.microsoft.com/en-us/office ... fileformat

Try this:
Change _DCFUNCT.PRG as follows:

Line 91: Was #DEFINE xlWorkbookNormal -4143
Line 91: Is #DEFINE xlWorkbookNormal 16

Rebuild DCLIPX.DLL by running BUILD20.BAT or BUILD19_SL1.BAT

Re: Question about the function: DC_WorkArea2Excel()

Posted: Thu Feb 06, 2020 10:57 pm
by Eugene Lutsenko
Hi, Roger! You helped me figure it out. Thank you very much! When I started looking at the file you sent in Excel, I saw the files created by the program. It turned out that this function writes the result (xls files) not to the folder where the program that launched it is located, but to "My documents". In other words, it should specify not just the filename, but the full path and file name. When I did this, everything worked as it should.