# Way to populate variable placeholder names into HTML template from Excel file?

**URL:** <https://boards.straightdope.com/t/way-to-populate-variable-placeholder-names-into-html-template-from-excel-file/939096>\
**Category:** Factual Questions\
**Created:** [March 31, 2021, 5:12pm UTC](https://boards.straightdope.com/t/way-to-populate-variable-placeholder-names-into-html-template-from-excel-file/939096 "2021-03-31T17:12:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![solost](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/solost/32/11776_2.png) [@solost](https://boards.straightdope.com/u/solost)\
**Post date:** [March 31, 2021, 5:12pm UTC](https://boards.straightdope.com/t/way-to-populate-variable-placeholder-names-into-html-template-from-excel-file/939096/1 "2021-03-31T17:12:22Z")

</div>

I am a front-end designer / developer for my company. I’ve been asked to look into ways to take an HTML banner ad template and generate hundreds or even thousands of versions with local business names. We would likely receive an Excel file with the hundreds of company names.

So the HTML ad template would consist of a headline saying something like:

BUY WIDGETS FROM [COMPANY NAME GOES HERE]

Then an Excel file with:

ABC Company  
DEF Company  
GHI Company  
(hundreds more…)

It seems like my boss is assuming that we would generate the localized versions in-house, and maybe that would be the best way, but I figure there are 3 main ways it could be done:

- Find an ad hosting vendor who will take the ad templates and spreasheet (probably in .CSV form?) and generate and place the localized versions themselves
- Find an out-of-box software or cloud-based solution to do this
- Build software to do the local version generation in-house

I’ve found a couple open-source software solutions that might be promising, one client-side Javascript based and one server-side PHP based, but other than that not a lot of solutions have jumped out at me, though it seems like a service that would have a pretty good market niche.

Any thoughts or ideas for me on this? I’m in the research stage right now, so any angle is welcome. Also, keep in mind my knowledge is more front-end than with back-ends or databases. Thanks!

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [March 31, 2021, 5:36pm UTC](https://boards.straightdope.com/t/way-to-populate-variable-placeholder-names-into-html-template-from-excel-file/939096/2 "2021-03-31T17:36:12Z")

</div>

What programming tools are you comfortable with? It seems like this could be done with a ~10 line Perl program.

---

<div class="post-metadata">

**Author:** ![solost](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/solost/32/11776_2.png) [@solost](https://boards.straightdope.com/u/solost)\
**Post date:** [March 31, 2021, 6:06pm UTC](https://boards.straightdope.com/t/way-to-populate-variable-placeholder-names-into-html-template-from-excel-file/939096/3 "2021-03-31T18:06:52Z")

</div>

As a front-end dev, really just Javascript and a little PHP.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [March 31, 2021, 6:24pm UTC](https://boards.straightdope.com/t/way-to-populate-variable-placeholder-names-into-html-template-from-excel-file/939096/4 "2021-03-31T18:24:07Z")

</div>

Well, PHP is somewhat similar to Perl. For the record, I would set up a process where the Excel file is exported to CSV, then a Perl (or any general purpose language with good string handling) reads each company name from the file, and for each name, reads the HTML template and substitutes the company name for a fixed pattern like “[COMPANY-NAME]” and writes it out to a new HTML file, perhaps with the company name embedded in the filename. Seems like that’s all you need.

---

<div class="post-metadata">

**Author:** ![GreenWyvern](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/greenwyvern/32/2834_2.png) [@GreenWyvern](https://boards.straightdope.com/u/GreenWyvern)\
**Post date:** [March 31, 2021, 6:34pm UTC](https://boards.straightdope.com/t/way-to-populate-variable-placeholder-names-into-html-template-from-excel-file/939096/5 "2021-03-31T18:34:26Z")

</div>

Yes, very easy to create a small Windows program to do it, reading the Excel file directly and writing out all the html files using the template.
