how to convert excel data to html files ?

chetan patel

New Member
Joined
Jan 1, 2015
Messages
2
i've an excel file with 10,000 rows and 3 columns.

I want to create separate html file for each row, hows this possible ?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
This small sample uses columns A, B, and C

Enter and run the following macro:

Code:
Sub HTMLMaker()
    Dim s1 As String, s2 As String, s3 As String
    Dim N As Long, i As Long, filespec As String
    N = Cells(Rows.Count, "A").End(xlUp).Row
    s1 = "<table><tr><td>"    s2 = "</td><td>"
    s3 = "</td></tr></table>"
[TABLE]
<tbody></tbody>[/TABLE]
    For i = 1 To N
        Close #1
        Open "C:\TestFolder\File" & i & ".html" For Output As #1
        Print #1, s1 & Cells(i, 1).Text & s2 & Cells(i, 2).Text & s2 & Cells(i, 3).Text & s3
    Next i
    Close #1
End Sub

Update first to meet your needs for folder and filename.
 
Upvote 0
Here is a working version:

Code:
Sub HTMLMaker()
    Dim s1 As String, s2 As String, s3 As String
    Dim N As Long, i As Long, filespec As String
    N = Cells(Rows.Count, "A").End(xlUp).Row
    s1 = "(table)(tr)(td)"
    s2 = "(/td)(td)"
    s3 = "(/td)(/tr)(/table)"
    s1 = Replace(Replace(s1, "(", "<"), ")", ">")
    s2 = Replace(Replace(s2, "(", "<"), ")", ">")
    s3 = Replace(Replace(s3, "(", "<"), ")", ">")
    For i = 1 To N
        Close #1
        Open "C:\TestFolder\File" & i & ".html" For Output As #1
        Print #1, s1 & Cells(i, 1).Text & s2 & Cells(i, 2).Text & s2 & Cells(i, 3).Text & s3
    Next i
    Close #1
End Sub
 
Upvote 0
Thanks for your time Gary but i am not that sharp in excel need more assistant on this


I've 9 columns in my excel file and i want a code which can create a separate html file for each row in this html format, html file name should be same as title


Columns are = BANK, IFSC,MICR CODE,BRANCH ADDRESS,CONTACT,CITY,DISTRICT,STATE


output should be this -------------------

<head>
<title>ABHYUDAYA COOPERATIVE BANK LIMITED RTGS-HO Branch IFSC MICR Code MUMBAI</title>
****** name="description" content="ABHYUDAYA COOPERATIVE BANK LIMITED RTGS-HO Branch IFSC MICR Code MUMBAI, DISTRICT - GREATER MUMBAI, STATE - MAHARASHTRA.">
</head>
<body>
BANK : ABHYUDAYA COOPERATIVE BANK LIMITED<br>
IFSC : ABHY0065001<br>
MICR CODE : 400065001<br>
BRANCH : RTGS-HO<br>
ADDRESS : ABHYUDAYA BANK BLDG., B.NO.71, NEHRU NAGAR, KURLA (E), MUMBAI-400024<br>
CONTACT : 25260173<br>
CITY : MUMBAI<br>
DISTRICT : GREATER MUMBAI<br>
STATE : MAHARASHTRA<br>
</body>




------------------------




let me know your thought...
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,985
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top