Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the points for attention in modifying statistical charts in OPENXML

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what are the matters needing attention in modifying statistical charts in OPENXML", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn "what are the points for attention in modifying statistical charts in OPENXML?" this article.

In the word document, you can establish a statistical chart through the excel table in the document. In the program development, you can find the statistical chart and modify a series of data, so as to achieve the effect of updating the statistical chart. Using openxml library, you can achieve the effect of modifying the data.

Use the decompression tool to open an example of a word document, word document contains statistical charts, found in the structure of the word document stored in an excel attachment, in the embeddings folder, so modify the statistical chart, be sure to modify this excel file synchronously.

First find the elements of the statistical chart in the document. In development, use ChartParts and select the chart element to modify according to the number of chart.

Var _ chartParts = _ mainDocPart.ChartParts

Find the attachment file of the statistical chart, get the excel file, and then deal with the data in the excel file and modify the row and column data in execel. For specific methods, see C# using OpenXML SDK to read Excel documents.

Var _ empart = _ chartParts.First () .EmbeddedPackagePart

Stream stream = _ empart.GetStream ()

Using (SpreadsheetDocument ssDoc = SpreadsheetDocument.Open (stream, true))

It should be noted that if the horizontal axis of the statistical chart is in time, the corresponding conversion needs to be done with ToOADate (OLE Automation date).

_ dateParm.ToOADate () .ToString ()

After modifying the excel, open word and find that the data of the statistical chart is not updated. Click to edit, the statistical chart is updated, because there is also a cache of data in the statistical chart, which needs to be modified synchronously.

Find the value of NumericValue from the statistical chart and modify the text according to the loop.

LineChartSeries bs1 = _ chartPart.ChartSpace.Descendants () .First ()

IEnumerable _ numCaches = bs1.Descendants ()

The above is all the contents of the article "what are the points for attention in modifying statistical charts in OPENXML?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report