Knowledgebase (2417)
Children categories
Automating Student Score Analysis and Ranking with Spire.Agent.Office
2026-08-07 07:50:53 Written by jie zouIn the field of education and academic affairs, processing exam scores after each test is one of the most frequent and time-consuming tasks. The same exam result often needs to be handled from two dimensions: for class students and class teachers, it needs to present the class's own score details, rankings, and subject strengths; for teachers and the academic affairs office, it needs cross-class horizontal comparison to determine which classes and subjects require focused attention.
The traditional approach usually requires manually writing formulas in Excel, sorting, drawing charts item by item, and writing analysis summaries. For different audiences, the same data must be reorganized twice, and the whole process often takes half a day to a full day. Formulas are error-prone, chart styles are inconsistent, and analysis criteria are hard to keep aligned.
Comparison with Traditional SDK API Processing
| Traditional Spire.Office for .NET API | Spire.Agent.Office Processing | |
|---|---|---|
| Driving Method | Write Excel formulas + file splitting + sorting + chart + conditional formatting code, controlling every step | Describe the goal in natural language; the AI understands and automatically orchestrates the execution path |
| Code Volume | Score analysis scenarios typically require 500-1000 lines of C# code (including per-class file splitting, formula calculation, ranking logic, chart configuration, etc.) | About 10 lines of calling code + one natural language instruction |
| Statistics Criteria | Must hard-code the calculation formulas and judgment logic for average/pass rate/excellence rate; adjusting criteria requires code changes | AI understands education statistics semantics and automatically computes by criteria such as "≥60 pass, ≥90 excellent" |
| Chart Generation | Must manually create Chart objects, configure data ranges, set chart types and styles | AI automatically selects the most appropriate chart type (radar, column, etc.) based on data semantics |
| Requirement Changes | Adding new statistics dimensions requires modifying code → compiling → deploying | Modify the description in the instruction; takes effect immediately |
This article introduces how to use the Excel AI capabilities of Spire.Agent.Office for two audiences — class students and teachers / the academic affairs office — to automate score statistics, ranking, and visual analysis with just a few natural language instructions.
For product installation and SpireToken configuration, please refer to Integrating Spire.Agent.Office in a .NET Project. The following examples assume Spire.Agent.Office is already installed and SpireToken is configured.
Class Score Statistics and Display
The score analysis for class students and class teachers focuses on the class itself: score details, in-class ranking, and subject strengths. Since there is no need for cross-class comparison, each class gets its own Excel file, which can be printed and posted, or used for parent meetings.
The following example uses the Spire.Agent.Office agent to automatically split data by class through natural language instructions and generate an independent score analysis Excel file for each class:
using Spire.Agent.Office.AI;
using Spire.Agent.Office.Extensions;
using Spire.Xls;
// Source score data (containing class, student name, and subject score columns)
string inputPath = @"C:\ScoreAnalysis\StudentScores.xlsx";
// Result document path (null uses the output folder path set below)
string savePath = null;
// Output directory (one file per class)
string OutDir = @"C:\ScoreAnalysis\ClassAnalysis";
// SpireToken Key
string key = "sk-TF***************************r";
// Natural language instruction
string instruction =
"Process the input file as follows:\r\n" +
"1. Read the file and generate one separate Excel analysis file per class, named 'XXClassScoreAnalysis.xlsx'\r\n" +
"2. Each class file must contain: the class score details, class ranking by total score, per-subject average/max/min, pass rate (≥60 points), excellence rate (≥90 points), and score interval distribution\r\n" +
"3. Choose appropriate chart types to visualize the class performance\r\n" +
"4. Apply a unified and clean table style: highlight the top 10 by total score in green, and mark failing subject scores in red";
// AI generation
AIResult result = AnalyzeClassScores(instruction, inputPath, savePath, key, OutDir);
// AI-assisted score analysis
static AIResult AnalyzeClassScores(string instruction, string inputpath, string savePath, string key, string output)
{
// Configure the AI processing options
AIOptions options = new AIOptions();
options.SpireToken = key;
options.WorkDir = output;
using (Workbook wb = new Workbook())
{
if (!string.IsNullOrEmpty(inputpath) && File.Exists(inputpath))
wb.LoadFromFile(inputpath);
AIDocumentProcessor processor = wb.AI(options);
return processor.ExecuteInstruction(wb, instruction, savePath);
}
}
Original score data and per-class score analysis files

Grade Score Summary and Analysis
The score analysis for teachers and the academic affairs office focuses on the overall picture: gaps between classes, subjects that are weak across the board, and the distribution of the full-grade ranking. All classes' data must be consolidated into a single worksheet to enable horizontal comparison, unified criteria, and decision support.
The following example uses the Spire.Agent.Office agent to consolidate all classes' data into one worksheet through natural language instructions, completing class comparison and visual analysis:
using Spire.Agent.Office.AI;
using Spire.Agent.Office.Extensions;
using Spire.Xls;
// Source score data (containing class, student name, and subject score columns)
string inputPath = @"C:\ScoreAnalysis\StudentScores.xlsx";
// Save path of the grade score analysis file
string savePath = @"C:\ScoreAnalysis\GradeAnalysis.xlsx";
// SpireToken Key
string key = "sk-TF***************************r";
// Natural language instruction
string instruction =
"Process the input file as follows:\r\n" +
"1. Read the file, and for each class calculate the average score, pass rate (≥60 points), and excellence rate (≥90 points) for every subject; generate a \"Class Comparison\" worksheet that summarizes these metrics for all classes.\r\n" +
"2. Generate the overall grade ranking based on total scores.\r\n" +
"3. Create radar charts for subject averages: one radar chart per class to show each class's own subject strengths, and a single combined radar chart that overlays all classes (each class as one series) for direct comparison.\r\n" +
"4. Based on the statistical data, analyze the overall performance of the entire grade, identify each class's strengths and weaknesses, and provide targeted improvement recommendations.";
// AI generation
AIResult result = AnalyzeGradeScores(instruction, inputPath, savePath, key);
// AI-assisted score analysis
static AIResult AnalyzeGradeScores(string instruction, string inputpath, string savePath, string key)
{
// Configure the AI processing options
AIOptions options = new AIOptions();
options.SpireToken = key;
using (Workbook wb = new Workbook())
{
if (!string.IsNullOrEmpty(inputpath) && File.Exists(inputpath))
wb.LoadFromFile(inputpath);
AIDocumentProcessor processor = wb.AI(options);
return processor.ExecuteInstruction(wb, instruction, savePath);
}
}
Original score data and grade score analysis result

Comparison of the Two Approaches
| Class Score Statistics and Display | Grade Score Summary and Analysis | |
|---|---|---|
| Audience | Class students, class teachers | Teachers, academic affairs office |
| Output | One independent Excel file per class | All classes consolidated into one Excel file |
| Core Content | In-class score details, in-class ranking, per-subject statistics, subject strength charts | Cross-class comparison, full-grade ranking, radar charts, score analysis conclusions |
| Typical Uses | Print and post, parent meetings | Teaching research reports, teaching decisions, academic affairs statistics |
Frequently Asked Questions
The chart type is not as expected
Cause: The chart type selected by the AI may not match the user's presentation preferences.
Solution: Specify chart type preferences explicitly in the instruction, such as "use radar charts for class subject strengths, column charts for score interval distribution, and line charts for score trends across multiple tests."
How to handle tied rankings
Cause: It is normal for multiple students to have the same total score; the AI's default handling of tied ranks may not meet your requirements.
Solution: Specify the tie-breaking rule in the instruction, such as "when total scores are equal, sort by Computer Science score first."
Obtaining a SpireToken Key
- Contact sales@e-iceblue.com or visit https://www.e-iceblue.com/TemLicense.html to obtain a trial/commercial API key
Configure it in code:
AIOptions options = new AIOptions();
options.SpireToken = key;
Generate PPT from Multi-Format Documents with Spire.Agent.Office
2026-08-03 03:09:15 Written by Lisa LiEfficiently transferring technical knowledge is a core challenge for every enterprise in day-to-day business. A large number of technical specification documents — such as operation manuals, safety and maintenance guides, and supply chain standard documents — are often dozens or even hundreds of pages long. How to quickly turn the core knowledge in these dense technical specifications into easy-to-understand PPT material is a key pain point in enterprise knowledge management.
This article demonstrates how to use the Spire.Agent.Office Presentation AI capability to analyze and summarize data sources in various formats, extract the core points, and generate professional PPT presentations.
- Generate PPT from a Word Document
- Generate PPT from a PDF Document
- Generate PPT from a Markdown Document
- Generate PPT from an Excel Document
Comparing with Traditional SDK/API Processing
| Traditional Spire.Office for .NET API | Spire.Agent.Office | |
|---|---|---|
| Driving approach | Requires calling the APIs of four products — Word, Excel, PDF, PowerPoint — extracting content from each document type via code, then calling the PowerPoint API to create slides page by page, add elements, and manually calculate layouts | Directly describe the requirement in natural language, and the AI understands and generates the PPT automatically |
| Development complexity | You need to be familiar with 4 different API sets, write separate parsing code for each format (.docx/.xlsx/.pdf), and then piece together the PowerPoint generation logic — large amount of code with high coupling | One natural-language instruction completes the entire workflow |
| Document parsing | You must manually specify which data to extract from each type of document; the parsing logic is hard-coded, and any document structure change requires synchronized code modification | AI automatically analyzes the document structure in depth and accurately extracts the key information |
| Versatility & maintainability | Each document format requires its own parsing logic; format changes or new document types require extensive code changes, with poor reusability | The same set of natural-language instructions adapts to different documents |
| Processing cycle | Several days (large documents require senior engineers to spend full time writing/debugging code) | Minutes (upload document + template + one instruction) |
Regarding product installation and SpireToken configuration, please refer to Integrating Spire.Agent.Office in a .NET Project. The examples below assume that Spire.Agent.Office is installed and SpireToken is configured.
Generate PPT from a Word Document
Generate a minimalist-style PPT presentation based on the content of a Word document according to a natural-language instruction.
using Spire.Agent.Office.AI;
using Spire.Agent.Office.Extensions;
using Spire.Presentation;
// Source data document
string inputPath = @"technical_requirements.docx";
// Result document path
string savePath = @"SafetyTechnicalRequirements.pptx";
// SpireToken Key
string key = "sk-TF***************************r";
// Natural language instruction
string instruction = "Extract the core points from 'technical_requirements.docx' to generate a PPT. 1. Ensure proper layout and formatting 2. Use a minimalist style with a light yellow theme 3. Generate 20 slides";
// AI generation
PPTGenerationResult result = GeneratePPT(inputPath, instruction, savePath, key);
// AI-assisted PPT generation
static PPTGenerationResult GeneratePPT(string input, string instruction, string savePath, string key)
{
AIOptions options = new AIOptions();
options.SpireToken = key;
options.TimeoutMs = 1000000;
using (Presentation ppt = new Presentation())
{
AIDocumentProcessor processor = ppt.AI(options);
return processor.GeneratePresentation(input, instruction, savePath);
}
}

Generate PPT from a PDF Document
Automatically analyze the internal hierarchy of a PDF document, accurately extract the key information, and generate a retro-green themed PPT presentation according to the instruction.
using Spire.Agent.Office.AI;
using Spire.Agent.Office.Extensions;
using Spire.Presentation;
// Source data document
string inputPath = @"procedures.pdf";
// Result document path
string savePath = @"SafetyOperationProcedures.pptx";
// SpireToken Key
string key = "sk-TF***************************r";
// Natural language instruction
string instruction = "Extract the key points from 'procedures.pdf' and generate a PPT. " +
"1. Ensure a well-structured layout and visual appeal; " +
"2. Include relevant diagrams and charts; " +
"3. Use a simple purple style as the theme; "+
"4. 9 pages";
// AI generation
PPTGenerationResult result = GeneratePPT(inputPath, instruction, savePath, key);
// AI-assisted PPT generation
static PPTGenerationResult GeneratePPT(string input, string instruction, string savePath, string key)
{
AIOptions options = new AIOptions();
options.SpireToken = key;
options.TimeoutMs = 1000000;
using (Presentation ppt = new Presentation())
{
AIDocumentProcessor processor = ppt.AI(options);
return processor.GeneratePresentation(input, instruction, savePath);
}
}

Generate PPT from a Markdown Document
Automatically summarize the content of a Markdown-format data source and generate a tech-style PPT.
using Spire.Agent.Office.AI;
using Spire.Agent.Office.Extensions;
using Spire.Presentation;
// Source data document
string inputPath = @"Management.md";
// Result document path
string savePath = @"SupplyChainManagement.pptx";
// SpireToken Key
string key = "sk-TF***************************r";
// Natural language instruction
string instruction = "Generate a PPT based on 'Management.md'. Requirements: 1. Adopt a tech/style; 2. Use light blue as the primary color scheme; 3. Ensure the core content is complete, with clear hierarchy and neat layout. Key data should be presented visually through charts and graphs.";
// AI generation
PPTGenerationResult result = GeneratePPT(inputPath, instruction, savePath, key);
// AI-assisted PPT generation
static PPTGenerationResult GeneratePPT(string input, string instruction, string savePath, string key)
{
AIOptions options = new AIOptions();
options.SpireToken = key;
options.TimeoutMs = 1000000;
using (Presentation ppt = new Presentation())
{
AIDocumentProcessor processor = ppt.AI(options);
return processor.GeneratePresentation(input, instruction, savePath);
}
}

Generate PPT from an Excel Document
Automatically summarize the content of an Excel-format data source and generate a tech-style PPT.
using Spire.Agent.Office.AI;
using Spire.Agent.Office.Extensions;
using Spire.Presentation;
// Source data document
string inputPath = @"data.xlsx";
// Result document path
string savePath = @"out.pptx";
// SpireToken Key
string key = "sk-TF***************************r";
// Natural language instruction
string instruction = "Generate a PPT based on data
.xlsx, 1. Ensure proper layout and formatting 2. Use a minimalist style with a light red theme 3. Ensure chart visual effects 4.Generate 15 pages";
// AI generation
PPTGenerationResult result = GeneratePPT(inputPath, instruction, savePath, key);
// AI-assisted PPT generation
static PPTGenerationResult GeneratePPT(string input, string instruction, string savePath, string key)
{
AIOptions options = new AIOptions();
options.SpireToken = key;
options.TimeoutMs = 1000000;
using (Presentation ppt = new Presentation())
{
AIDocumentProcessor processor = ppt.AI(options);
return processor.GeneratePresentation(input, instruction, savePath);
}
}

FAQ
The number of generated PPT pages does not match the expectation
Cause: If the data source contains a large amount of content, the AI analysis will take more time. The default timeout of AIOptions.TimeoutMs is 5 minutes; if the analysis exceeds it, the AI analysis is interrupted.
Solution: Set AIOptions.TimeoutMs to a sufficiently large value, and also specify a page range in the instruction, e.g. "Keep the final PPT to 8-12 pages".
The key content extracted by AI is not accurate enough
Cause: The source document has a complex structure, and the AI may not have fully understood the hierarchy.
Solution: Explicitly specify the type of content to extract in the instruction, e.g. "Focus on extracting the data from the table in Chapter 2".
Get Your SpireToken Key
- Contact sales@e-iceblue.com or visit https://www.e-iceblue.com/TemLicense.html to obtain a trial/commercial API key
Configure it in code:
AIProcessorOptions options = new AIProcessorOptions();
options.SpireToken = key;
OFD (Open Fixed-layout Document) is a national standard fixed-layout document format widely used in e-invoices, e-certificates, administrative approvals, and other government and financial scenarios. OFD describes document structure based on XML, offering advantages such as independent control and information security. Meanwhile, PDF remains indispensable as an internationally recognized document format for cross-platform distribution. Real-world business often requires flexible switching between the two formats: receiving OFD-format e-invoices and converting them to PDF for printing and distribution, or converting existing PDF contracts to OFD to meet government platform upload requirements.
Spire.PDF for JavaScript performs bidirectional conversion between PDF and OFD entirely in the browser via WebAssembly, managing input and output files through a virtual file system (VFS) with no backend server required.
This article covers two core features:
For installation and project setup, refer to Integrating Spire.PDF for JavaScript in a React Project. The examples below assume Spire.PDF is installed and the WebAssembly module is initialized.
Convert PDF to OFD
The core of PDF-to-OFD conversion is to re-encode the page content, fonts, and graphics elements from a PDF document into an XML description structure compliant with the OFD standard. Spire.PDF for JavaScript accomplishes this in one step through the PdfDocument object's SaveToFile method with the FileFormat.OFD enum value, eliminating the need to handle underlying format differences manually.
function App() {
const convertToOFD = async () => {
// Get the Spire.PDF WASM module
const pdfModule = window.wasmModule?.spirepdf;
// Check if the WASM module is ready
if (!pdfModule) {
alert('Spire.PDF is not ready yet');
return;
}
// Load fonts and PDF file into VFS
await window.spire.FetchFileToVFS('ARIAL.TTF', '/Library/Fonts/', `${process.env.PUBLIC_URL}/font/`);
const inputFileName = 'TemplateIntroduction-en.pdf';
await window.spire.FetchFileToVFS(inputFileName, "", `${process.env.PUBLIC_URL}/data/`);
// Create PdfDocument object and load the PDF document
let doc = new pdfModule.PdfDocument();
doc.LoadFromFile(inputFileName);
// Define the output file name for OFD format
const outputFileName = 'OutputOFD.ofd';
// Save as OFD format
doc.SaveToFile({ fileName: outputFileName, fileFormat: pdfModule.FileFormat.OFD });
doc.Close();
// Read the converted file from VFS and trigger download
const fileArray = window.dotnetRuntime.Module.FS.readFile(outputFileName);
const blob = new Blob([fileArray], { type: 'application/ofd' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = outputFileName;
a.click();
URL.revokeObjectURL(url);
};
return (
<div style={{ textAlign: 'center', height: '300px' }}>
<h1>Convert PDF To OFD</h1>
<button onClick={convertToOFD}>
Generate
</button>
</div>
);
}
export default App;
OFD output generated after conversion via SaveToFile with FileFormat.OFD

Convert OFD to PDF
OFD-to-PDF conversion is a common requirement in government electronic document distribution scenarios. Spire.PDF for JavaScript provides the OfdConverter component, which is specifically designed to parse OFD fixed-layout documents and export them as standard PDF files while preserving the original document's layout and visual appearance.
function App() {
const convertOFDToPDF = async () => {
// Get the Spire.PDF WASM module
const pdfModule = window.wasmModule?.spirepdf;
// Check if the WASM module is ready
if (!pdfModule) {
alert('Spire.PDF is not ready yet');
return;
}
// Load fonts and OFD file into VFS
await window.spire.FetchFileToVFS('Arial.TTF', '/Library/Fonts/', `${process.env.PUBLIC_URL}/font/`);
const inputFileName = 'Invoice_EN.ofd';
await window.spire.FetchFileToVFS(inputFileName, "", `${process.env.PUBLIC_URL}/data/`);
// Create OfdConverter object and pass the OFD file path
let converter = new pdfModule.OfdConverter(inputFileName);
// Define the output file name for PDF format
const outputFileName = 'OutputPDF.pdf';
// Convert to PDF format
converter.ToPdf(outputFileName);
converter.Dispose();
// Read the converted file from VFS and trigger download
const fileArray = window.dotnetRuntime.Module.FS.readFile(outputFileName);
const blob = new Blob([fileArray], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = outputFileName;
a.click();
URL.revokeObjectURL(url);
};
return (
<div style={{ textAlign: 'center', height: '300px' }}>
<h1>Convert OFD To PDF</h1>
<button onClick={convertOFDToPDF}>
Generate
</button>
</div>
);
}
export default App;
Standard PDF output generated after conversion via OfdConverter

FAQ
Can encrypted PDFs be converted to OFD?
Password-protected encrypted PDFs cannot be saved as OFD directly via SaveToFile — the document must be decrypted first.
Solution: Provide the password when loading the PDF via the second parameter of LoadFromFile, then save as OFD:
// Load a password-protected PDF document
let doc = new pdfModule.PdfDocument();
doc.LoadFromFile(inputFileName, "password");
// Save as OFD format
doc.SaveToFile({ fileName: outputFileName, fileFormat: pdfModule.FileFormat.OFD });
doc.Close();
Garbled text in the converted OFD document
OFD relies on font embedding to ensure consistent cross-platform rendering. If the input PDF uses non-embedded fonts and the corresponding font files are not loaded in the VFS, text may appear garbled after conversion.
Solution: Make sure the required TrueType font files (e.g., ARIALUNI.TTF) are loaded into the /Library/Fonts/ directory in VFS before calling the conversion. ARIALUNI.TTF covers common CJK characters and is the recommended font for ensuring conversion quality.
Get a Free License
Spire.PDF for JavaScript offers a 30-day full-featured free trial license with no functional limitations. Apply here to evaluate before purchasing.