In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to use OpenXML to read Excel documents in C#, the content is very detailed, interested friends can refer to, hope to be helpful to you.
OpenXML is an official Microsoft open source operation Word, Excel and PPT SDK, developed with C #, using this kind of library can easily operate the three main types of office documents, and do not need to install Office programs.
Here is a list of how to use OpenXML to read the contents of an Excel document:
First of all, use nuget to install the class library reference of OpenXML, or you can download the class library directly from the Internet for reference
Add Namespace
Using DocumentFormat.OpenXml.Packaging;using DocumentFormat.OpenXml.Spreadsheet; uses code to open an Excel document using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open ("file path", false)) {WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; / / Select the sheet page of Excel, corresponding to the actual order in Excel WorksheetPart worksheetPart = workbookPart.WorksheetParts.ElementAt (1); / / the content in the sheet page SheetData _ Sheet1data = worksheetPart.Worksheet.Elements (). First () / / some Chinese and English contents such as headings in Excel will be placed in SharedStringTable var _ sharepart = workbookPart.SharedStringTablePart;// circular Excel table row data foreach (Row rin _ Sheet1data.Elements ()) {/ / data foreach (Cell c in r.Elements ()) {string text = c.CellValue.Text in each Cell data / / determine whether to if (c.DataType! = null) {var _ xmlpart = _ sharepart.SharedStringTable.ElementAt (Convert.ToInt32 (c.CellValue.Text)) in SharedStringTable; text = _ xmlpart.FirstChild.InnerText;} / / finally get text data}} on how to use OpenXML to read Excel documents in C# is shared here. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.