|
| Inicio → WINDEV 2024 → Add data in the second worksheet and third worksheet when we do table to excel function |
| Add data in the second worksheet and third worksheet when we do table to excel function |
| Iniciado por nishit_devani, 02,mar. 2016 11:27 - 5 respuestas |
| |
| | | |
|
| |
| Publicado el 02,marzo 2016 - 11:27 |
Hello,
We have a requirement where we are using TabletoExcel function to export the data in excel. But it gets exported only on first worksheet. So what we have to do if we want the data to be exported in multiple worksheets of a excel.
For example :
We are using the following code which creates multiple worksheet with data exported in the 1st worksheet (Budget Description) . So if we want to export data in 2nd worksheet (Currency)also then how we will do in Windev :
sFilename is string="BUDGET_"+gsUsername+"_"+ DateToString(DateSys(),"YYYYMMDD") +"_"+ TimeToString(TimeSys(),"HHMMSS")+".xls" sFilename = CompleteDir(fExeDir()) + sFilename TableToExcel(TABLE_Budget_Directory_Excel, sFilename)
fCreate(CompleteDir(fExeDir()) + sFilename)
MyXLSDocument is xlsDocument MyXLSDocument = xlsOpen(sFilename, xlsWrite) MyXLSDocument..WorksheetName="Budget Description" IF xlsNbWorksheet(MyXLSDocument) = 1 THEN xlsAddWorksheet(MyXLSDocument, "Currency") xlsAddWorksheet(MyXLSDocument, "Simulation Base") xlsAddWorksheet(MyXLSDocument, "Export to PIMS") END xlsSave(MyXLSDocument) xlsClose(MyXLSDocument)
Thanks, Nishit. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 02,marzo 2016 - 12:50 |
HI
AFAIK, you'll need to use OLE automation to do that
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM (open source)
More information on http://www.fabriceharari.com
On 3/2/2016 5:27 AM, Nishit wrote:
Hello,
We have a requirement where we are using TabletoExcel function to export the data in excel. But it gets exported only on first worksheet. So what we have to do if we want the data to be exported in multiple worksheets of a excel.
For example : We are using the following code which creates multiple worksheet with data exported in the 1st worksheet (Budget Description) . So if we want to export data in 2nd worksheet (Currency)also then how we will do in Windev :
sFilename is string="BUDGET_"+gsUsername+"_"+ DateToString(DateSys(),"YYYYMMDD") +"_"+ TimeToString(TimeSys(),"HHMMSS")+".xls" sFilename = CompleteDir(fExeDir()) + sFilename TableToExcel(TABLE_Budget_Directory_Excel, sFilename)
fCreate(CompleteDir(fExeDir()) + sFilename)
MyXLSDocument is xlsDocument MyXLSDocument = xlsOpen(sFilename, xlsWrite) MyXLSDocument..WorksheetName="Budget Description" IF xlsNbWorksheet(MyXLSDocument) = 1 THEN xlsAddWorksheet(MyXLSDocument, "Currency") xlsAddWorksheet(MyXLSDocument, "Simulation Base") xlsAddWorksheet(MyXLSDocument, "Export to PIMS") END xlsSave(MyXLSDocument) xlsClose(MyXLSDocument)
Thanks, Nishit. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,marzo 2016 - 08:49 |
Thanks for the reply.
One more thing when I try protect the excel sheets using the code:
excel>>Activeworksheet>>"1">>Protect("abc")
It gives error Protect method does not exist.
So do we have to define the method or there is some other function to be used for protecting the excel
Thanks, Nishit. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,marzo 2016 - 10:55 |
Hi
You can use all the methods available in excel VBA. I have no idea if protect is one of them, as this is a VBA question, and not a windev one. For that, I guess that MSDN is your friend.
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM (open source)
More information on http://www.fabriceharari.com
On 3/3/2016 2:49 AM, Nishit wrote:
Thanks for the reply.
One more thing when I try protect the excel sheets using the code:
excel>>Activeworksheet>>"1">>Protect("abc")
It gives error Protect method does not exist.
So do we have to define the method or there is some other function to be used for protecting the excel
Thanks, Nishit. |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 102 mensajes |
|
| Publicado el 03,marzo 2016 - 12:56 |
Nishit,
I'm not shure what your question is. But you can write to different worksheets in your Excel file like this:
Procedure test() xlsDatei is xlsDocument bRes is boolean FOR i = 1 TO 3 bRes = xlsAddWorksheet(xlsDatei,"Tabelle"+i) xlsCurrentWorksheet(xlsDatei,i) xlsDatei[1,1] = "Test " + i END xlsSave(xlsDatei,"E:\temp\test.xlsx") xlsClose(xlsDatei)
HTH Sebastian
-- http://arnoldconsult.de WinDev 20 with Oracle, WinDevMobile Android Apps and Motorola Windows CE Mobile Barcode Scanners, Python 3 with Oracle and MySQL |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,marzo 2016 - 05:48 |
Hello ,
Thank you all for the feedback and suggestions.
I have managed to protect the excel file on export using the following code:
objXLApp>>Worksheets(sSheetnm)>>Protect("abcd",True,True, True)
Regards, Nishit. |
| |
| |
| | | |
|
| | | | |
| | |
|