WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Editor version 6.2
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Display Excel Data in Dialog

 Keywords: Display Excel XLS XLSX CSV Data TABLE HTML Dialog ADO ADODB GetString udfXLStoHTMLTable

;***************************************************************************
;**
;**       Convert XLS data into HTML Table
;**
;***************************************************************************
#DefineFunction udfXLStoHTMLTable(xlsfile, sqlstring)
   ; Convert XLS data into HTML Table
   ; Notes: Uses ADO Jet Provider and GetString
   ; Developer: Deana Falk 2011.04.06
   If ! FileExist( xlsfile ) Then Exit
   adStateOpen=1
   adOpenForwardOnly=0
   adLockReadOnly=1
   adCmdText=1

   objConnection = CreateObject("ADODB.Connection")
   objRecordSet = CreateObject("ADODB.Recordset")
   objConnection.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" : xlsfile : ";Extended Properties=Excel 8.0;"

   objRecordSet.Open(sqlstring, objConnection, adOpenForwardOnly, adLockReadOnly)
   tabledata =objRecordSet.GetString(,-1,"</TD><TD>","</TD></TR><TR><TD>","N/A" )

   htmlbegin = '<html><table border cellpadding="1" cellspacing="1" summary="subject for the table content"><td>'
   htmlend = '</table></html>'

   objRecordSet.Close
   objConnection.Close
   objConnection = 0
   objRecordSet = 0
   Return htmlbegin:tabledata:htmlend
#EndFunction

xlsfile  = 'D:\data\data.xls'
htmlfile =  'D:\data\table.html'
sheetname = 'sheet1'
sqlstr = 'SELECT * FROM [':sheetname:'$]'

htmldata = udfXLStoHTMLTable( xlsfile, sqlstr)
FilePut( htmlfile,htmldata )

;***************************************************************************
;**
;**       Display HTML data in Dialog
;**
;***************************************************************************
MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`XLS Data Viewer`
MyDialogX=372
MyDialogY=169
MyDialogWidth=554
MyDialogHeight=360
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`207,333,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`297,333,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`001,001,548,324,COMCONTROL,"ComControl_1",DEFAULT,"`:htmlfile:`",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")
Exit

Article ID:   W17717
Filename:   Display Excel Data in Dialog.txt
File Created: 2011:04:07:10:05:26
Last Updated: 2011:04:07:10:05:26