DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • What Is mTLS? How To Implement It With Istio
  • How To Design Reliable IIoT Architecture
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023
  • What Is Test Pyramid: Getting Started With Test Automation Pyramid

Trending

  • What Is mTLS? How To Implement It With Istio
  • How To Design Reliable IIoT Architecture
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023
  • What Is Test Pyramid: Getting Started With Test Automation Pyramid
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Using Open XML SDK v2.0 on Windows Azure

Using Open XML SDK v2.0 on Windows Azure

Sudheendra Kovalam user avatar by
Sudheendra Kovalam
·
Feb. 21, 11 · News
Like (0)
Save
Tweet
Share
7.29K Views

Join the DZone community and get the full member experience.

Join For Free

generating word/excel reports is a fairly common requirement. now that we intend to migrate our application to the cloud, we realize that on windows azure you do not have  office dlls or in fact, any other (unnecessary from azure’s perspective) dlls available to you. you can always package office dlls with your app deployment package and use them in your application on windows azure (you can find articles on the blogosphere about how this can be done).

i opted for using open xml sdk v2.0 available here . i can generate word / excel reports on the fly.

here’s a sample code to write to create a word document

//using statements required
using documentformat.openxml;
using documentformat.openxml.packaging;
using documentformat.openxml.wordprocessing;      

//code to create a word document at the provided file path
using (wordprocessingdocument worddocument =
    	wordprocessingdocument.create(filepath, wordprocessingdocumenttype.document))
    		{
   			mainpart.document = new document(
   				new body(
   					new paragraph(
   						new run(
   							new text("report generated by open xml sdk ")))));
   			worddocument.maindocumentpart.document.save();
   			worddocument.close();
   		}

now that we have everything in place we want to deploy this “report generation solution” to the cloud, but first we'll run it locally on the compute emulator.

everything seems to be working, next step is to deploy your application to your azure account.

this blog post talks about a known issue on using open xml sdk in  .net 4 roles on windows azure.

when you right click your solution to do a publish...

image

windows azure would ask you for the hosted service where you want to deploy the solution, if you have not already set that up, the dialog box also has a provision to do that for you.

image

please remember to uncheck, (you read that right) “ uncheck ” enable intellitrace for .net 4 roles.

you may want to argue that intellitrace helps us in historical debugging in an event  of a fatal crash, but for now you will have to live with the windows azure diagnostics logging for now.

the reason, why this needs to be disabled is, “enabling intellitrace for .net 4 roles when using the open xml sdk seems to freeze your web/worker role.”

i learnt this the hard way (after being billed for a week for a extra large vm (frozen, just because i enabled intellitrace and am using open xml sdk in my azure app). in other words, that’s a lot of money. crying face crying face crying face

keep reading this space for such posts to come. i am working on windows azure now, so i am sure there are many such topics on which i can post. smile


azure Software development kit XML

Published at DZone with permission of Sudheendra Kovalam. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • What Is mTLS? How To Implement It With Istio
  • How To Design Reliable IIoT Architecture
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023
  • What Is Test Pyramid: Getting Started With Test Automation Pyramid

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: