GitHunt
TH

thnhmai06/SlideGenerator.Framework

A .NET framework for generating PowerPoint files from Excel data

SlideGenerator.Framework

.NET 10 EmguCV CodeFactor Lines of Code License

A powerful, standalone .NET library for orchestrating the generation of PowerPoint presentations from Excel data sources. It provides high-level abstractions for template manipulation, data extraction, and intelligent image processing.

Documentation: English | Tiแบฟng Viแป‡t

Modules

The framework is composed of four core modules:

Module Namespace Description
โ˜๏ธ Cloud SlideGenerator.Framework.Cloud Resolves direct download links from Google Drive, OneDrive, and Google Photos.
๐Ÿ“Š Sheet SlideGenerator.Framework.Sheet efficient reading of Excel (.xlsx) and CSV files.
๐Ÿ–ผ๏ธ Slide SlideGenerator.Framework.Slide PowerPoint manipulation: template loading, slide cloning, text/image replacement.
๐Ÿง  Image SlideGenerator.Framework.Image Advanced image processing: Face detection, ROI (Region of Interest) cropping, resizing.

Prerequisites

EmguCV Runtime

This framework relies on EmguCV for computer vision tasks. You must install the native runtime package matching your target OS in the consuming project.

OS Package
Windows (x64) Emgu.CV.runtime.windows
Linux (x64) Emgu.CV.runtime.ubuntu-x64
Linux (ARM) Emgu.CV.runtime.debian-arm
Linux (ARM64) Emgu.CV.runtime.debian-arm64

๐Ÿ”— Official EmguCV Installation Guide

Project Configuration Example:

<ItemGroup Condition="'$(RuntimeIdentifier)'=='win-x64'">
    <PackageReference Include="Emgu.CV.runtime.windows" Version="4.12.0.5764" />
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)'=='linux-x64'">
    <PackageReference Include="Emgu.CV.runtime.ubuntu-x64" Version="4.12.0.5764" />
</ItemGroup>

Note: macOS is currently not supported due to EmguCV runtime limitations in this context.

Usage

โ˜๏ธ Cloud Module

Resolve shareable links to direct raw image streams.

using SlideGenerator.Framework.Cloud;

var directUrl = await CloudUrlResolver.ResolveLinkAsync("https://drive.google.com/file/d/...");

๐Ÿ“Š Sheet Module

Read data from spreadsheets.

using SlideGenerator.Framework.Sheet.Models;

using var workbook = new Workbook("data.xlsx");
var sheet = workbook.Worksheets["Sheet1"];
var rowData = sheet.GetRow(1); // Returns Dictionary<string, object>

๐Ÿ–ผ๏ธ Slide Module

The core generation logic.

using SlideGenerator.Framework.Slide.Models;
using SlideGenerator.Framework.Slide;

// 1. Load Template & Create Output
using var template = new TemplatePresentation("template.pptx");
using var working = template.SaveAs("output.pptx");

// 2. Clone a slide from template
var slidePart = working.CopySlide(template.MainSlideRelationshipId);

// 3. Replace Text
var replacements = new Dictionary<string, string>
{
    ["Name"] = "Alice",
    ["Title"] = "Engineer"
};
await TextReplacer.ReplaceAsync(slidePart, replacements);

// 4. Replace Image (by Shape ID)
var shapeId = 4U; // Discovered via template.GetAllPreviewImageShapes()
var shape = Presentation.GetShapeById(slidePart, shapeId);
using var imgStream = File.OpenRead("photo.png");

ImageReplacer.ReplaceImage(slidePart, shape!, imgStream);

// 5. Save
working.Save();

๐Ÿง  Image Module

Intelligent cropping based on Region of Interest (ROI).

using SlideGenerator.Framework.Image.Models;
using SlideGenerator.Framework.Image.Modules.Roi;

using var image = new Image("photo.png");
using var faceModel = new YuNetModel(); // Pre-trained face detector

var roiModule = new RoiModule(new RoiOptions { FaceDetectionModel = faceModel });
var selector = roiModule.GetRoiSelector(RoiType.Face);

// Crop image focusing on the face
await RoiModule.CropToRoiAsync(image, new Size(200, 200), selector, CropType.Fill);

Star History

Star History Chart

Contributors


thnhmai06

Hair-Nguyeenx
๐Ÿ‘‘ ๐Ÿ’ป ๐Ÿ’ป
thnhmai06/SlideGenerator.Framework | GitHunt