项目作者: niklaskarl

项目描述 :
.NET Standard Library to create and manipulate Open XML Documents (Word, Excel, Powerpoint)
高级语言: C#
项目地址: git://github.com/niklaskarl/BinaryMesh.OpenXml.git
创建时间: 2021-02-23T22:16:37Z
项目社区:https://github.com/niklaskarl/BinaryMesh.OpenXml

开源协议:MIT License

下载


BinaryMesh.OpenXml

🚧🚧🚧 This library is under construction 🚧🚧🚧

Currently Available Features

Presentations

  • Creating and opening presentations
  • Inserting slides based on layouts
  • Creating Shapes
  • Editing text of shapes
  • Formating Shapes
  • Creating Charts

    Spreadsheets

  • Creating and opening spreadsheets
  • Inserting sheets
  • Setting Values of Cells
  • Reading Cells

Planed Features

Presentations

  • Advanced Shapes
  • Pictures
  • Even more formatting
  • Even more charts
  • Rich Text in Shapes
  • Spreadsheets

  • Formatting
  • Wordprocessing

  • Basic support

Example API for creating Presentations

  1. using BinaryMesh.OpenXml.Presentations;
  2. using BinaryMesh.OpenXml.Spreadsheets;
  3. using (IPresentationDocument document = PresentationFactory.CreatePresentationDocument())
  4. {
  5. IPresentation = document.Presentation;
  6. ISlide titleSlide = presentation.InsertSlide(presentation.SlideMasters["Office"].SlideLayouts["Title"]);
  7. titleSlide.VisualTree["Title 1"].AsShapeVisual()
  8. .SetText("Automated Presentation Documents made easy")
  9. titleSlide.VisualTree["Subtitle 2"].AsShapeVisual()
  10. .SetText("BinaryMesh.OpenXml is an open-source library to easily and intuitively create OpenXml documents")
  11. IChartSpace pieChartSpace = presentation.CreateChartSpace();
  12. IPieChart pieChart = pieChartSpace.InsertPieChart();
  13. using (ISpreadsheetDocument spreadsheet = pieChartSpace.OpenSpreadsheetDocument())
  14. {
  15. ISheet sheet = spreadsheet.Workbook.Sheets["Sheet 1"];
  16. sheet.Cells["B1"].SetValue("Revenue");
  17. sheet.Cells["A2"].SetValue("2019");
  18. sheet.Cells["A2"].SetValue(1000);
  19. sheet.Cells["B3"].SetValue("2020");
  20. sheet.Cells["B3"].SetValue(1875.13);
  21. sheet.Cells["C4"].SetValue("2021");
  22. sheet.Cells["C4"].SetValue(874.86);
  23. pieChart.Series.SetTextRange(sheet.GetRange("$B$1"));
  24. pieChart.Series.SetCategoryRange(sheet.GetRange("$A$2:$A$5"));
  25. pieChart.Series.SetValueRange(sheet.GetRange("$B$2:$B$5"));
  26. }
  27. ISlide statisticsSlide = presentation.InsertSlide(presentation.SlideMasters["Office"].SlideLayouts["Only Title"]);
  28. titleSlide.VisualTree["Title 1"].AsShapeVisual()
  29. .SetText("A basic Chart");
  30. titleSlide.VisualTree.InsertGraphicFrame("Diagramm 1")
  31. .SetOffset(2032000, 719666)
  32. .SetExtend(8128000, 5418667)
  33. .SetContent(pieChartSpace);
  34. // write presentation to a destination file and close it.
  35. using (Stream destination = new FileStream("presentation.pptx"))
  36. {
  37. document.Close(destination);
  38. }
  39. }