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

Samples from Users

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

Display Spreadsheet as HTML

 Keywords:  

Import CSV file using OWC Spreadsheet Output to HTML then display in Browser.

Run on Win98 with Office 2002/Web Components Installed

NOTE: in this example the csv file is pre-created, it could be as a result of a database query, or a LAFF database. The result set is displayed as read-only, but I believe there is a way to make Excel the ContentType for the HTML in which case you could edit the cell contents.

; Winbatch - Import CSV file using OWC Spreadsheet
;            Output to HTML then display in Browser
;
; Run on Win98 with Office 2002/Web Components Installed
;
; NOTE: in this example the csv file is pre-created, it
;       could be as a result of a database query, or a
;       LAFF database. The result set is displayed as
;       read-only, but I believe there is a way to make
;       Excel the ContentType for the HTML in which case
;       you could edit the cell contents.
;
;            Stan Littlefield, November 9, 2003
;/////////////////////////////////////////////////////

; standard IE Explorer Window UDF
#definesubroutine startMSIE(cURL)
   BoxOpen("Please Wait...","Loading %cURL%...")
   Browser = objectopen("InternetExplorer.Application")
   Browser.TheaterMode = @false
   ; but make it resizable
   Browser.Resizable = @true
   Browser.addressbar = @false
   Browser.statusbar = @false
   Browser.menubar = @true     ; to allow printing
   Browser.toolbar = @false
   browser.visible = @false
   browser.navigate(cURL)
   While Browser.busy || Browser.readystate <> 4
      timedelay(0.5)
   EndWhile
   BoxShut()
   browser.visible = @true
   browserDoc = Browser.Document
   all = browserdoc.all
   return(browser)
#endsubroutine

;//// start of script
; is the Web Component Installed?
If ! RegExistKey(@REGCLASSES,"OWC.Spreadsheet") Then Message("Cannot Continue",StrCat("Office Web Components",@CRLF,"Are Not Installed.") )
intcontrol(73, 1, 0, 0, 0)

; files
cCSV = StrCat(dirget(),"Products.csv")
If ! FileExist(cCSV) Then Exit
cURL = StrCat(dirget(),"PRODUCTS.HTM")
If FileExist(cURL) Then FileDelete(cURL)

; create spreadsheet from csv file
BoxOpen("Creating %cURL%","Please Wait...")
oS            = ObjectOpen("OWC.Spreadsheet")
oS.DataType   = "CSVURL"
oS.CSVURL     = cCSV
oSheet        = oS.ActiveSheet
oRange        = oSheet.UsedRange
oRange.Select
oRange.AutoFitColumns
oI            = oRange.Interior
oI.Color      = "CornSilk"
ObjectClose(oI)
oFont         = oRange.Font
oFont.Bold    = @TRUE
ObjectClose(oFont)
ObjectClose(oRange)
oSheet.Export(cURL, 0)
ObjectClose(oSheet)
ObjectClose(oS)
;///// end of spreadsheet creation

BoxShut()
; display in Browser
br = startMSIE(cURL)
ObjectClose(br)


Exit

:WBERRORHANDLER
intcontrol(73, 1, 0, 0, 0)
return
exit
;//////////////////////////////////////////////////////


Products.csv

"Product Id","Products","Supplier ID","Category ID","Unit","Unit Price","In Stock","On Order","Re-Order Amt.","Discontinued"
1,"Chai",1,1,"10 boxes x 20 bags",18.00000,39,0,10,
2,"Chang",1,1,"24 - 12 oz bottles",19.00000,17,40,25,
3,"Aniseed Syrup",1,2,"12 - 550 ml bottles",10.00000,13,70,25,
4,"Chef Anton's Cajun Seasoning",2,2,"48 - 6 oz jars",22.00000,53,0,0,
5,"Chef Anton's Gumbo Mix",2,2,"36 boxes",21.35000,0,0,0,20031109
6,"Grandma's Boysenberry Spread",3,2,"12 - 8 oz jars",25.00000,120,0,25,
7,"Uncle Bob's Organic Dried Pears",3,7,"12 - 1 lb pkgs.",30.00000,15,0,10,
8,"Northwoods Cranberry Sauce",3,2,"12 - 12 oz jars",40.00000,6,0,0,
9,"Mishi Kobe Niku",4,6,"18 - 500 g pkgs.",97.00000,29,0,0,20031109
10,"Ikura",4,8,"12 - 200 ml jars",31.00000,31,0,0,

Article ID:   W16653
File Created: 2005:02:18:12:21:46
Last Updated: 2005:02:18:12:21:46