Recently, I was working with a prototype of web application. Since I was building a prototype, I simply used table utility in Word 2007 to create table and used its formatting to create nice looking tables.
I simply copy-pasted it in design view of Visual Studio in my ASP.NET web project.
This worked fine for small prototype. Problem is that this create internal stylesheets for each <td>, <tr>, <p>,...
When I was asked to convert this to external stylesheets, it created a lot of problems (since I had to remove all internal style="…" attribute from each tag and associate with similar class from external stylesheet).
Also, I faced a strange problem. After replacing style=:q with empty string, I still had some 1000 style attributes that were not replaced. The problem was attributes like
style="font-size: 12pt; color: black; font-family: 'Cambria','serif'; mso-ascii-theme-font: major-latin;
mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: major-fareast;
mso-hansi-theme-font: major-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: major-bidi;
mso-themecolor: text1"
was not replaced since they were multi-line. I had regular expression style=("([^"]\n)*") to replace these attributes.
Lessons learnt:
- Regular Expression make Find Replace dialog very powerful.
- Never use Word 2007 (though it allows you to rapidly develop professional looking tables) in your ASP application
No comments:
Post a Comment