简体   繁体   中英

create a report from template using C# excel OpenXML API

I've been using Microsoft COM model to prepare reports but it is slow and fails if server does not have excel installed. So I am moving to using OpenXML for creating reports from a server process that does a ton of other things as well.

I've a template that contains named ranges for data that I need to change or extend, named charts, named chart series, named worksheets, etc. All my formatting is contained in excel file and all I do in my server side process is populate the file with data.

These are the steps that I need to replicate using Excel OpenXML:

  1. Open an existing sheet and create a new sheet based on it.
  2. Get the worksheet by worksheet name
  3. Get the Named Ranges in that worksheet.
  4. Populate the Named Ranges from data and extend the ranges if required based on data set.
  5. Get Chart by Chart Name
  6. Get Chart Series by Series Title
  7. Set Chart series to the new range
  8. Export Chart to jpeg to be used in html.
  9. Save new File.

Is it possible to do these steps in OpenXML cleanly? Any examples will help me a lot. Or a light weight library that does this. Some of these 3rd party libraries are too big and are more useful in creating new sheets from scratch.

Any help appreciated.

AFAIK, with OpenXml you can do anything.

I recommend a ClosedXml lib, it wraps OpenXML SDK and makes it easier to do your job. Link contains samples and stuff. Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM