Creating Word Document Using .NET

30. October 2008

I recently had to create a Word document dynamically using .NET.

Dim filename As String = "testfile.doc"
Dim file As FileStream = New FileStream(Server.MapPath(Request.ApplicationPath & ("/documents/" & filename)), FileMode.OpenOrCreate, FileAccess.Write)
Dim Writer As StreamWriter = New StreamWriter(file)
Dim strBody As New StringBuilder("")
strBody.Append("<html xmlns:o='urn:schemas-microsoft-com:office:office' " & _
"xmlns:w='urn:schemas-microsoft-com:office:word'" & _
"xmlns='http://www.w3.org/TR/REC-html40'" & _
"><head><title>Document Title</title>")
strBody.Append("<!--[if gte mso 9]><xml>" & _
"<w:WordDocument> <w:View>" & _
"Print</w:View> <BR>" & _
"<w:Zoom>90</w:Zoom> " & _
"<w:DoNotOptimizeForBrowser/>" & _
"</w:WordDocument></xml><![endif]-->")
strBody.Append("<style><!-- /* Style Definitions" & _
" */@page Section1{size:8.27in 11.69in;" & _
"margin:.5in 1.0in .5in 1.0in;" & _
"mso-page-orientation:portrait;" & _
"mso-header-margin:.5in; " & _
"mso-footer-margin:.5in; mso-paper-source:0;" & _
"font-family: Arial; font-size: 10pt; }")
strBody.Append("div.Section1{page:Section1;}--></style></head>")
strBody.Append("div.Section1 {page:Section1;}")
strBody.Append("<style><!-- /* Style Definitions" & _
" */@page Section1{size:8.27in 11.69in;" & _
"margin:.5in 1.0in .5in 1.0in;" & _
"mso-page-orientation:portrait;" & _
"mso-header-margin:.5in; " & _
"mso-footer-margin:5in; mso-paper-source:0;" & _
"font-family: Arial; font-size: 10pt; }")
strBody.Append("div.Section1{page:Section1;}--></style></head>")
strBody.Append("div.Section1 {page:Section1;}")
strBody.Append("<body lang=EN-UK style='tab-interval:.5in'><div class=Section1>")
strBody.Append("YOUR CONTENT GOES HERE")
strBody.Append("</div></body></html>")
Writer.Write(strBody.ToString)
Writer.Close()
file.Close()

The above will create the word document to open in Page Layout and as an A4 Portrait. If you need it to be in landscape then change the style definitions to

strBody.Append("<style><!-- /* Style Definitions" & _
" */@page Section1{size:11.0in 8.5in;" & _
"margin:0.45in 0.35in 0.35in 0.35in;" & _
"mso-page-orientation: landscape;" & _
"mso-header-margin:.5in;" & _
"mso-footer-margin:.5in; mso-paper-source:0;" & _
"font-family: Arial; font-size: 10pt; }")

Thanks to Alistair Gillespie for his help with the final code.

.Net

Local Businesses Should Take Advantage of Homecoming Scotland 2009

30. October 2008

Homecoming Scotland 2009 celebrates the 250th anniversary of Robert Burns' birth. It's also celebrating some of Scotland’s great contributions to the world: golf, whisky, great minds and innovations and Scotland's rich ancestry and culture.

Local businesses in Scotland should be using this as an advertising opportunity with Google AdWords™. Searching Google for Homecoming Scotland and no one is advertising. Come Back To Ayrshire, South Ayrshire's Homecoming Scotland website, has one advert. There will be a world record number of Burns Suppers in January and so far the AdWord adverts are few.

The Scottish Government is going to be heavily promoting Homecoming Scotland 2009 as will the local councils. Perhaps advertising just now is too early but come January when the events start it would certainly be worth investing in advertising your business with Homecoming Scotland keywords.

Suitable keywords might be: burns supper, Homecoming Scotland, homecoming, come back to Ayrshire, Robert Burns, home of golf, drive it home (for US, Canada and Sweden residents).

Website Promotion , ,

Recession Proof Your Website

29. October 2008

A global recession may be upon us and now is the time to get your website in order. More businesses will fail while the rest will fight for every last online user.

You can give your website an edge over competitors by making simple changes that will boost your page rankings and attract more users.

Improve Your Title!

Make sure you put relevant keywords in your page title. Don’t just use “About Us” put something more meaningful so that the page title effectively describes the content of the page. So “About Us | Cheap Blackberry Phones Best Deals From Company Y”.

Use Your Meta Tags

Don’t forget to have meta description and keywords in the <head /> tag. Have a unique description for each page. Make sure the keywords are on the page content.

Structure Your Headings

Have only one <h1 /> tag and then have the rest of your headings in order e.g. h1, h2, h3. Use the headings to put more important information higher up on the page. Use the heading tags properly and don’t abuse them. Search engines assign the greatest importance to <h1 />, then <h2 />, and so on.

Filenames Are Important

Don’t go naming your page files page1.htm or abbreviations like ips.htm. Use a descriptive file name cheap-iphones.htm or blackberry-sale.htm. Search engines also search the page filename for the keywords users search on. So if your filename contains the keywords used on the page then this will increase your page rankings.

A Site Map Is Essential

If you have a small website you can quickly create a site map. This will be an index of your website and make it easier for search engines and crawlers to index your content. For details of how to create a site map check out http://www.sitemaps.org/protocol.php. Then sign up to Google Webmaster tools (http://www.google.com/webmasters/tools/) and add your site map for Google to crawl. Plus, use your robots file (http://www.robotstxt.org/ for more information) to help the crawlers crawl all your pages. Insert sitemap: http://yourdomain.com/sitemap.xml.

Get Listed!

This is important. If you want to boost your page ranking to attract more users then get your website listed in directories and on other websites. There are many free directories you can get your website listed on. Join forums related to your website business or service and always put your url in your posts and replies. Search for related websites and see if you can have your website link listed. Always use a meaningful descriptive text link not just your company or website name, for example Latest Blackberry Phones.

Simple Changes Can Make A Big Difference

These simple website improvements can help improve your page rankings and drive more traffic to your website. Just what you need when a recession is looming.

Website Promotion ,

Find Accessible Websites With Net-Guide

26. October 2008

net-guide is an accessible search engine promoting the accessibility rating of each website.

Whilst many search engines are easy to use for people with visual impairments, mobility issues, learning difficulties and other issues that impact on using a website, this is not necessarily true of the sites returned in the results. It is estimated that as many as 86% of websites present barriers to some or all of these user groups. Continually visiting websites that are not accessible can be a very frustrating experience.

net-guide is a search engine that gives an accessibility rating for every website returned for a search. Similarly, the directory entries also carry an accessibility rating.

Visit net-guide for more information.

Accessibility, Usability, Website Promotion ,

Write An Article, Drive Traffic

25. October 2008

Driving traffic to your website can be difficult. By writing good keyword rich articles and putting them on websites such as hubpages and squidoo can help drive targeted traffic to your website.

This can be a simple and free way to promote your website. Known as Article Marketing, the more articles you write the more traffic your website will attract. And that means more sales for you.

Writing articles is time consuming so if you are unsure of doing it yourself why not try my website promotion service.

 

Website Promotion ,

South Ayrshire Council

25. October 2008

I am currently improving the South Ayrshire Council website to meet at least the Double A accessibility standards. You will find that I have even surpassed that on many pages by making them Triple A compliant. Using XHTML web standards along with accessibility standards I have improved page performance and made the converted pages more accessible to users. Through Search Engine Optimisation techniques I have also improved the page rankings.

The updated pages are being built with ASP.NET using VB.NET.

More About South Ayrshire

South Ayrshire is an ideal base for family holidays. Long stretches of sandy beach, superb sports and recreational facilities and entertainment have helped make Ayr one of Britain's premier coastal resorts. Troon is also a popular holiday resort with its soft sandy award-winning beach overlooking the Isle of Arran. The towns esplanade offers various facilities for families including crazy golf and putting. Girvan is proud of its reputation for floral attractions and colourful displays which are situated in many parts of the town and include the Rose Gardens, Knockcushan Gardens and Orchard Gardens. The town is also a good base for exploring on foot or by bike the Carrick Forest and the many picturesque villages of the surrounding Carrick area.

From Burns Cottage to Culzean Castle, South Ayrshire is full of history and culture. The leisure is not too bad either! Play on some of the best golf courses in Scotland along with the world famous Royal Troon and Turnberry. Given its coastal location, there are also plenty of opportunities to take to the water for fun. Troons bustling harbour is a magnet for anglers, sightseers and yachting enthusiasts who can enjoy the first-class facilities of the Troon Yacht Haven, one of the Clyde's leading sailing centres. Sea-angling trips operate from Ayr as does the world's last sea-going paddle steamer PS Waverley which takes cruisers on trips down the Firth of Clyde during the summer.

.Net, Accessibility, General, SEO services, Usability , , ,



Marketing & SEO Blogs - Blog Top SitesBlog Flux Directory Marketing / SEO Top Blogs Internet Marketing & SEO (Link Building) - TOP.ORG Add to Technorati Favorites TopOfBlogs