FelisShape 0.5.8-rc1
dotnet add package FelisShape --version 0.5.8-rc1
NuGet\Install-Package FelisShape -Version 0.5.8-rc1
<PackageReference Include="FelisShape" Version="0.5.8-rc1" />
paket add FelisShape --version 0.5.8-rc1
#r "nuget: FelisShape, 0.5.8-rc1"
// Install FelisShape as a Cake Addin
#addin nuget:?package=FelisShape&version=0.5.8-rc1&prerelease
// Install FelisShape as a Cake Tool
#tool nuget:?package=FelisShape&version=0.5.8-rc1&prerelease
FelisShape
FelisShape is a .NET library for manipulating the presentations which conform to the Office Open XML File Formats specification. It is a platform-independent library base on the Open XML SDK.
Installation
dotnet add package FelisShape
Namespace
The basic namespace is FelisOpenXml.FelisShape
.
Some class may be contained in sub-namespace such as FelisOpenXml.FelisShape.Draw
and so on.
Basic Usage
Presentation
Load a presentation from a stream:
var pres = new FelisPresentaion(soureceStream);
Create a empty presentation taken an other one as the template:
var template = new FelisPresentaion(templateStream);
var target = FelisPresentation.From(template);
Save a presentation:
// pres is an instance of FelisPresentation
pres.Save(targetStream); // save to a stream
pres.Save("filePath.pptx"); // save to a file
Slide
Enumerating the slides in a presentation
// pres is an instance of FelisPresentation
foreach (var slide in pres.Slides)
{
// TODO: ...
}
Insert a duplicate of a slide into a presentation
pres.InsertSlide(sourceSlide, indexForInsertingAt);
Remove a slide in a presentation
slide.Remove();
// or
pres.RemoveSlide(slide);
Edit a customer data in a slide
slide.WorkWithCustomerData("nameOfTheData", (XmlDocument dataDoc) =>
{
// TODO: ...
return true; // Return true means there is some changings should be commited to the slide. Otherwise return false.
}, true);
// The last argument of WorkWithCustomerData means if a new customer data should be created when there is no existing one.
// The default value is false.
Remove a customer data in a slide
slide.RemoveCustomerData("nameOfTheData");
Sumbit any changings in the slide
slide.Submit();
// Notice: Without invoking this method, the changings in the slide may be lost after close the presentation.
Shapes
Enumerating the shapes in a slide
foreach (var shape in slide.Shapes)
{
// TODO: ...
}
Get a shape by a given ID in a slide or in a shapes group
slideOrGroup.GetShapeById(id);
Get a shape with a special type a slide or in a shapes group
slideOrGroup.GetShapes<T>();
// The T can be one of follows:
// FelisShape
// FelisPicture
// FelisTable
// FelisChart
// FelisConnectionShape
// FelisOleObject
// FelisShapeGroup
Manipulating the data of the shape
The id of the shape
Console.WriteLine(shape.Id);
shape.Id = newId;
The name of the shape
Console.WriteLine(shape.Name);
shape.Name = newName;
The rect of the shape
var rect = shape.Rect;
shape.Rect = new FelisShapeRect() { x = 0, y = 0, cx = 100, cy = 100 };
The rect of the shape, the coordinate is relative to the parent shape
var ret = shape.RelativeRect;
shape.RelativeRect = new FelisShapeRect() { x = 0, y = 0, cx = 100, cy = 100 };
The text in the shape
Console.WriteLine(shape.TextBody?.Text);
shape.TextBody.Text = "Hello world";
The fill of the shape
var fill = new FelisSolidFillValue();
fill.Color.Value = Color.FromArgb(255, 0, 0);
shape.Fill = fill;
See the API document for more information
Season Studio Copyright(2023)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- DocumentFormat.OpenXml (>= 2.19.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Upgrade from 0.5.7 for:
- Add same extension method to the OpenXmlElement-base object to make the tasks of searching or locating the element easily.
- Add method for manipulating the eaternal workbook of the chart
- Using "AddChild" for inserting the children element first to make sure that the element is locating in the correct postion.
- Fix the bug that the deep searching of the shapes' tree is invalid