Scott on Writing

Musings on technical writing...

Excel as a Code Generator

I have been up in Orange County these past few days doing one-on-one training and consulting with an individual wanting to take his .NET skills to the next level.  In any event, he showed me a neat little shortcut he uses for creating his ASP.NET Web pages and code-behind classes.  In his job as an independent contractor, he is working for a company that needs a lot of data entry Web Forms, all of which are gargantuous in the amount of data needed to be collected.  For example, he'll get sent an Excel spreadsheet listing over 200 fields they want to capture in a Web Form.

Clearly creating a Web Form with 200 Web controls could take all day; adding the code to insert the data into the table could take another full day.  And, to top it off, both tasks are extremely repetitive and boring.  This gentleman's solution, I thought, was rather clever.  He creates an Excel spreadsheet and copies over the names and descriptions of the fields they want.  He then specifies the database fields these various entries refer to.  Then, for each row in the spreadsheet, he has a few columns that essentially piece together the values in the other columns along with code or HTML/Web control markup.  The end result?  After he has copied over the 200 fields and descriptions and has specified the database fields the input fields relate to, he can literally just cut and paste the generated HTML into the HTML view in VS.NET and his UI is done.  He can then cut and paste the database updating/inserting code into his code-behind class, and he's just about finished the Web Form.

Granted, he should be using a DAL and business objects, and a tool specifically designed for code generation, like CodeSmith or LLBL Gen, but, regardless, I had never thought of Excel as a tool one would use to generate HTML and source code.  Neat.

posted on Thursday, August 21, 2003 3:38 PM

Feedback

# re: Excel as a Code Generator 8/22/2003 5:04 AM Jack Herrington

I'd really like to know more about this. Could you post some screenshots?

# re: Excel as a Code Generator 8/22/2003 7:39 AM Scott Mitchell

Jack, let me talk to my client today and see if he is interested in sharing his tool/work with others. I'll get back to you...

# re: Excel as a Code Generator 8/22/2003 5:16 PM Scott Mitchell

Jack, heard back from my client - said he wants to clean up the interface a bit, and then he plans on releasing it to all. I'll make a blog entry post once this becomes a reality.

Thanks...

# re: Excel as a Code Generator 8/23/2003 5:18 AM Simon Willison

I used this technique many years ago, when running the web site for an online gaming league. I didn't know any server side programming languages but I needed to create some huge HTML tables showing the current standings of the different teams in the league. I ended up creating the table in Excel, then using simple Excel string operations in a final column to glue together the necessary HTML for a row that represents that data. I could then change the data in the tables, then copy and paste the HTML column over to my text editor.

# re: Excel as a Code Generator 9/4/2003 4:21 PM Damian

I have used a technique like this doing data imports for clients.
You get some horrible looking spreadsheet that DTS will choke on, use a simple cell formula to concatenate the fields into an INSERT statement. Then you just paste all the insert statements into Query Analyzer and run it.

Makes life so much easier sometimes.

# Generating a List of Unattached Databases 4/26/2006 6:38 PM Scott on Writing

# Generating a List of Unattached Databases 5/2/2006 12:47 AM Brian E. Cooper

<p>SQL Server databases are implemented as physical files with the MDF extension. They can be attached...

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<March 2010>
SMTWTFS
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Comment Stats

DayTotal% of Total
Sunday 2056.8%
Monday 42514.1%
Tuesday 51917.2%
Wednesday 55618.4%
Thursday 58019.2%
Friday 54718.1%
Saturday 1886.2%
Total 3020100.0%

Hour1Total% of Total
12:00 AM 782.6%
1:00 AM 812.7%
2:00 AM 682.3%
3:00 AM 822.7%
4:00 AM 692.3%
5:00 AM 1264.2%
6:00 AM 1193.9%
7:00 AM 1816.0%
8:00 AM 1926.4%
9:00 AM 1585.2%
10:00 AM 1886.2%
11:00 AM 1936.4%
12:00 PM 2016.7%
1:00 PM 1846.1%
2:00 PM 1695.6%
3:00 PM 1354.5%
4:00 PM 1153.8%
5:00 PM 1073.5%
6:00 PM 1013.3%
7:00 PM 1073.5%
8:00 PM 923.0%
9:00 PM 882.9%
10:00 PM 913.0%
11:00 PM 953.1%
Total 3020100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.00160
Monday 4.80384
Tuesday 4.04477
Wednesday 7.39680
Thursday 6.26676
Friday 5.07466
Saturday 4.78177
Total 5.403020

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 3.8550
8:00 AM 3.72134
9:00 AM 6.06297
10:00 AM 5.63276
11:00 AM 4.22194
12:00 PM 6.16351
1:00 PM 3.09133
2:00 PM 4.89230
3:00 PM 7.67322
4:00 PM 4.00108
5:00 PM 6.07170
6:00 PM 4.64116
7:00 PM 8.95188
8:00 PM 8.63164
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.403020

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles