C++ tutorial for Excel to OFD conversion

In the world of document management, the OFD (Open Fixed-layout Document) format is gaining significant traction, particularly in East Asian markets, as a domestic alternative to PDF. Whether you are developing financial reporting software or an enterprise document management system, the need to convert Excel to OFD in C++ environments is becoming increasingly common.

This guide provides a comprehensive tutorial on how to convert Excel spreadsheets (XLS/XLSX) to OFD format using Spire.XLS for C++, a robust library designed to handle Excel operations without requiring Microsoft Office to be installed.


Why Convert Excel to OFD?

Before diving into the code, it is essential to understand the benefits of OFD conversion:

  • Immutable Format: OFD preserves the layout, fonts, and images of your Excel sheets, ensuring they look the same on any device.
  • Standard Compliance: As a national standard in China (GB/T 33190-2016), OFD is often required for government and archival submissions.
  • Compact Size: OFD files are typically smaller than Excel files with rich images/formatting while maintaining high quality.

Setting Up Spire.XLS for C++

The first step is to integrate the library into your project. The easiest method is to use the official NuGet package or manually include the files.

Option A: Install via NuGet Package Manager

  • Open your project in Visual Studio.
  • Go to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...
  • Search for "Spire.XLS.Cpp".
  • Click "Install".

Option B: Manual Installation

  • Download the latest version of Spire.XLS for C++ from the official website.
  • Unzip the package.
  • Configure your Visual Studio project to include the Include directory path and link the lib directory. Ensure the DLL files are placed in the same directory as your executable or in a system path.

For detailed installation instructions, see: Integrate Spire.XLS for C++ in a C++ Application


Basic Excel to OFD Conversion in C++

Once the Excel library is set up, you can write the code to load an Excel document (.xls or .xlsx) and save it as an OFD.

Here is a complete C++ example:

#include "Spire.Xls.o.h"

using namespace Spire::Xls;
using namespace std;

int main() {

	wstring inputFile = L"Budget.xlsx";
	wstring outputFile = L"ExcelToOFD.ofd";

	// Create a new Workbook object
	intrusive_ptr<Workbook> workbook = new Workbook();

	// Load the workbook from the specified input file
	workbook->LoadFromFile(inputFile.c_str());

	// Save the workbook to the OFD format
	workbook->SaveToFile(outputFile.c_str(), FileFormat::OFD);

	// Dispose of the workbook object.
	workbook->Dispose();
}

Key Code Explanations:

  • Create Workbook: The Workbook class represents the entire Excel file and handles loading/saving operations.
  • Load Excel File: The LoadFromFile method reads your source Excel document.
  • Save as OFD: The SaveToFile method with the FileFormat::OFD enum converts the spreadsheet data into the fixed-layout OFD format.

Excel to OFD conversion result:

Convert an Excel file to OFD format using CPP

The code converts each sheet in the Excel file to a separate page in the OFD document. If you need to convert only a specific worksheet, you can copy the worksheet to a new workbook first and then use the above code for conversion.


Advanced Excel to OFD Conversion Settings

To gain finer control over how your spreadsheets appear in the final OFD document, Spire.XLS for CPP provides several options to tailor the OFD output. Below are two practical advanced configurations:

Fit Excel Sheet to One Page in OFD Output

By default, when an Excel worksheet is larger than a standard page, it may be split across multiple OFD pages. This can break the visual flow of your data. Spire.XLS for C++ provides the ConverterSetting class to customize Excel conversion, and by setting its SetSheetFitToPage method to true, you can fit each worksheet to a single OFD page.

Core implementation code:

intrusive_ptr<Workbook> workbook = new Workbook();
workbook->LoadFromFile(L"Sample.xlsx");

// Enable fit to one page
workbook->GetConverterSetting()->SetSheetFitToPage(true);

workbook->SaveToFile(L"FittedSheet.ofd", FileFormat::OFD);
workbook->Dispose();

What the code does:

  • If the worksheet’s content exceeds the page dimensions, the library scales it down proportionally to fit on a single page.
  • This ensures that a wide table or chart is not split awkwardly across pages.

Adjust Page Setup Before Conversion

For more precise control, you can modify the PageSetup properties of individual worksheets. This allows you to set the paper orientation, margins, paper size, and more—just as you would in Excel's Page Layout view.

Core implementation code:

intrusive_ptr<Workbook> workbook = new Workbook();
workbook->LoadFromFile(L"Sample.xlsx");

// Access the first worksheet
intrusive_ptr<Worksheet> sheet = dynamic_pointer_cast<Worksheet>(workbook->GetWorksheets()->Get(0));

// Get the PageSetup object of this worksheet
intrusive_ptr<PageSetup> pageSetup = dynamic_pointer_cast<PageSetup>(sheet->GetPageSetup());

// Set orientation to Landscape
pageSetup->SetOrientation(PageOrientationType::Landscape);

//Set the paper size to A4 paper
pageSetup->SetPaperSize(PaperSizeType::PaperA4);

// Set custom margins (in inches)
pageSetup->SetBottomMargin(2);
pageSetup->SetLeftMargin(1);
pageSetup->SetRightMargin(1);
pageSetup->SetTopMargin(2);

workbook->SaveToFile(L"CustomPageSetup.ofd", FileFormat::OFD);

What the code does:

  • Orientation: Changes the page orientation to landscape (ideal for wide tables).
  • Margins: Sets custom margins around the content.
  • Paper Size: Sets the page size to A4 (options include PaperA4, PaperLetter, PaperLegal, etc.).
  • Per‑sheet control: You can apply different settings to each worksheet before conversion.

Pro Tip: If your workflow requires broader compatibility, Spire.XLS for C++ also supports direct Excel to PDF conversion, giving you the flexibility to output to either format depending on your regional or archival requirements.


Frequently Asked Questions (FAQs)

Q1. Do I need Microsoft Excel installed on my server to use Spire.XLS for C++?

A: No. Spire.XLS for C++ is a completely independent library. It does not require Microsoft Office or Excel to be installed on the machine where the application is deployed. This makes it ideal for server-side deployments.

Q2. Does the conversion support all Excel elements (Charts, Pivot Tables, Shapes)?

A: Yes. The library is designed to preserve high-fidelity. Elements such as charts, shapes, images, formulas (as calculated values), and pivot tables are rendered accurately in the output OFD file, maintaining the visual appearance of the original spreadsheet.

Q3. Can I skip a worksheet and converts the rest to OFD?

A: Yes. You can hide unwanted worksheets before conversion (Spire.XLS for C++ skips hidden sheets):

//Hide the the first worksheet
workbook->GetWorksheets()->Get(0)->SetVisibility(WorksheetVisibility::Hidden);

Alternatively, copy the desired sheet to a new workbook as mentioned earlier.

Q4: Does Spire.XLS for CPP support batch converting multiple Excel files to OFD?

A: Yes. You can loop through all Excel files in a specified folder and convert them to OFD in batches.


Conclusion

Converting Excel to OFD in C++ is both straightforward and scalable with Spire.XLS for C++. Whether you need to convert a single spreadsheet or automate batch processing, the library delivers high‑performance results with minimal code. By using advanced settings like fit‑to‑page and custom page setup, you can ensure your OFD documents meet exacting presentation standards.

For more features such as Excel encryption, data writing, or formula calculation, explore the official documentation.


Get a Free License

To fully experience the capabilities of Spire.XLS for C++ without any watermarks or limitations, you can request a 30-day trial license here.

Convert Python Code to Word Files

Developers often need to include Python code inside Word documents for technical documentation, tutorials, code reviews, internal reports, or client deliverables. While copying and pasting code manually works for small snippets, automated solutions provide better consistency, formatting control, and scalability — especially when working with long scripts or multiple files.

This tutorial demonstrates multiple practical methods to export Python code into Word documents using Python. Each method has its own strengths depending on whether you prioritize formatting, automation, syntax highlighting, or readability.

On This Page:

Install Required Libraries

Install the necessary dependencies before running the examples:

pip install spire.doc pygments

Library Overview:

  • Spire.Doc for Python — used to create and manipulate Word documents programmatically
  • Pygments — used to generate syntax-highlighted code in RTF, HTML, or image formats
  • Pathlib (built-in) — used for reading Python files from disk
  • textwrap (built-in) — used to wrap long code lines before generating images formatting

Export Python Code to Word as Plain Text

Plain text insertion is the most straightforward method for embedding code in Word. It keeps scripts fully editable and preserves formatting such as indentation and line breaks.

Method 1. Insert Raw Python Code into a Word Document

This method reads a .py file and inserts the code directly into Word while applying a monospace font style.

from pathlib import Path
from spire.doc import *

# Read Python file
code_string = Path("demo.py").read_text(encoding="utf-8")

# Create a Word document
doc = Document()

# Add a section
section = doc.AddSection()
section.PageSetup.Margins.All = 60

# Add a paragraph
paragraph = section.AddParagraph()

# Insert code string to the paragraph
paragraph.AppendText(code_string)

# Create a paragraph style
style = ParagraphStyle(doc)
style.Name = "code"
style.CharacterFormat.FontName = "Consolas"
style.CharacterFormat.FontSize = 12
style.ParagraphFormat.LineSpacing = 12
doc.Styles.Add(style)

# Apply the style to the paragraph
paragraph.ApplyStyle("code")

# Save the document
doc.SaveToFile("Output.docx", FileFormat.Docx2019)
doc.Dispose()

How It Works:

This technique treats Python code as plain text and inserts it directly into a Word paragraph. The script reads the .py file using Path.read_text(), preserving indentation, blank lines, and overall structure.

After inserting the text, a custom paragraph style is created and applied. The use of a monospace font such as Consolas ensures alignment and readability, while fixed line spacing maintains consistent formatting across lines.

Because no intermediate format is used, this is the simplest and fastest approach. However, it does not provide syntax highlighting or semantic styling—Word only displays the code as formatted text.

Output:

Insert Python Code into Word

You May Also Like: Generate Word Documents Using Python

Method 2. Generate a Word File from Markdown-Wrapped Code

If your workflow already uses Markdown, wrapping Python code inside fenced blocks provides a structured way to convert scripts into Word documents.

from pathlib import Path
from spire.doc import *

# Read Python file
code = Path("demo.py").read_text(encoding="utf-8")

# Convert to Markdown
md_content = f"```python\n{code}\n```"
Path("temp.md").write_text(md_content, encoding="utf-8")

# Load Markdown into Word
doc = Document()
doc.LoadFromFile("temp.md")

# Update page settings
doc.Sections[0].PageSetup.Margins.All = 60

# Save as a DOCX file
doc.SaveToFile("Output.docx", FileFormat.Docx)
doc.Dispose()

How It Works:

Instead of inserting text directly, this method wraps Python code inside Markdown fenced code blocks. The generated Markdown file is then loaded into Word using Spire.Doc’s Markdown parsing capability.

When Word imports Markdown, it automatically preserves code formatting such as indentation and line breaks. This approach is useful when your documentation workflow already uses Markdown or when code needs to coexist with headings, lists, and descriptive text.

Since Markdown itself does not inherently apply syntax coloring inside Word, the result is still plain code formatting—but the structure is cleaner and easier to manage within technical documentation pipelines.

Output:

Convert Markdown-Wrapped Code to Word

Add Syntax-Highlighted Python Code to Word

Syntax highlighting makes code easier to read and understand. By integrating Pygments, Python scripts can be converted into stylized formats before being embedded into Word.

This section explores three approaches — RTF, HTML, and image rendering — each with different strengths depending on your formatting goals.

Method 1. Use RTF for Preformatted Code Blocks

RTF allows syntax-highlighted code to remain fully editable within Word.

from pathlib import Path
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import RtfFormatter
from spire.doc import *

# Read Python file
code = Path("demo.py").read_text(encoding="utf-8")

# Set font
formatter = RtfFormatter(fontface ="Consolas")

# Specify the lexer
rtf_text = highlight(code, PythonLexer(), formatter)
rtf_text = rtf_text.replace(r"\f0", r"\f0\fs24") # font size (24 for 12-point font)

# Create a Word document
doc = Document()

# Add a section
section = doc.AddSection()
section.PageSetup.Margins.All = 60

# Add a paragraph
paragraph = section.AddParagraph()

# Insert the syntax-highlighted code as RTF
paragraph.AppendRTF(rtf_text)

# Save the document
doc.SaveToFile("Output.docx", FileFormat.Docx2019)
doc.Dispose()

How It Works:

Pygments analyzes Python syntax using a lexer, identifying tokens such as keywords, strings, and comments. The RTF formatter applies styling rules that represent colors and fonts using RTF control words.

The resulting RTF string is inserted directly into Word using AppendRTF(). Because RTF is a native Word-compatible format, the document preserves fonts, colors, and spacing without requiring additional rendering steps.

Font size is controlled by modifying RTF control words (e.g., \fs24), allowing precise control over appearance. This method produces editable, selectable code with syntax highlighting inside Word.

Output:

Convert Code to Word with Syntax Highlighting via RTF

Method 2. Render Highlighted Code via HTML Formatting

HTML rendering provides visually rich syntax highlighting and automatic text wrapping.

from pathlib import Path
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
from spire.doc import *

# Read Python file
code = Path("demo.py").read_text(encoding="utf-8")

# Generate HTML from the Python code with syntax highlighting
html_text = highlight(code, PythonLexer(), HtmlFormatter(full=True))

# Create a Word document
doc = Document()

# Add a section
section = doc.AddSection()
section.PageSetup.Margins.All = 60

# Add a paragraph
paragraph = section.AddParagraph()

# Add the HTML string to the paragraph
paragraph.AppendHTML(html_text)

# Save the document
doc.SaveToFile("Output.docx", FileFormat.Docx2019)
doc.Dispose()

How It Works:

Here, Pygments converts Python code into styled HTML using the HtmlFormatter. The HTML output includes inline styles or CSS rules that represent syntax colors and formatting.

Spire.Doc then interprets the HTML content and renders it into Word. During this process, HTML elements are translated into Word formatting structures, allowing the highlighted code to appear visually similar to web-based code blocks.

This approach is ideal when code originates from web content, static documentation sites, or Markdown-to-HTML workflows.

Output:

Convert Code to Word with Syntax Highlighting via HTML

You May Also Like: Convert HTML to Word DOC or DOCX in Python

Method 3. Insert Syntax-Highlighted Code as Images

For scenarios where visual consistency matters more than editability, code can be rendered as an image before insertion.

from pathlib import Path
import textwrap
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import ImageFormatter
from spire.doc import *

# Read Python file
code = Path("demo.py").read_text(encoding="utf-8")

# Wrap long lines manually
def wrap_code_lines(code_text, max_width=75):
    wrapped_lines = []
    for line in code_text.splitlines():
        if len(line) > max_width:
            wrapped_lines.extend(textwrap.wrap(
                line,
                width=max_width,
                replace_whitespace=False,
                drop_whitespace=False
            ))
        else:
            wrapped_lines.append(line)
    return "\n".join(wrapped_lines)

code = wrap_code_lines(code, max_width=75)

# Step 3: Generate image
formatter = ImageFormatter(
    font_name="Consolas",
    font_size=18,
    scale=2,            
    image_pad=10,
    line_pad=2,
    background_color="#ffffff"
)

img_bytes = highlight(code, PythonLexer(), formatter)

with open("code.png", "wb") as f:
    f.write(img_bytes)

# Create a Word document
doc = Document()
section = doc.AddSection()
section.PageSetup.Margins.All = 60

# Insert into Word
paragraph = section.AddParagraph()
picture = paragraph.AppendPicture("code.png")

# Ensure image fits page width
page_width = (
    section.PageSetup.PageSize.Width
    - section.PageSetup.Margins.Left
    - section.PageSetup.Margins.Right
)
picture.Width = page_width

# Save the document
doc.SaveToFile("Output.docx", FileFormat.Docx2019)
doc.Dispose()

How It Works:

This method renders Python code as an image instead of editable text. Pygments generates a syntax-highlighted bitmap using the ImageFormatter, allowing full visual control over fonts, colors, padding, and DPI.

Since image rendering does not automatically wrap long lines, the script manually wraps lengthy code lines using Python’s textwrap module before generating the image. This prevents oversized images that exceed page width.

After inserting the image into Word, its width is dynamically resized to fit the printable page area. Because the code is embedded as a graphic, it preserves exact visual appearance across platforms and prevents formatting inconsistencies—but the text is no longer editable.

Output:

Insert Syntax-Highlighted Code as Images in Word

Conclusion

Converting Python code to Word documents can be achieved through several approaches depending on your goals. Plain text methods provide simplicity and flexibility, while RTF and HTML techniques offer powerful syntax highlighting with selectable text. Image-based code blocks deliver consistent visual formatting but require careful line wrapping and scaling.

For most documentation workflows:

  • Use plain text for editable technical content
  • Use HTML or RTF for syntax-highlighted documentation
  • Use images when formatting consistency is critical

FAQs

Which method is best for tutorials?

HTML or RTF methods provide clear syntax highlighting with selectable text.

How can I preserve indentation and blank lines?

Read the .py file using .read_text() without stripping or modifying lines.

Why do image-based code blocks become too small?

Word scales images to fit page width. Increasing the image formatter’s scale or adjusting the wrapping width can improve readability.

Can readers copy code from Word?

Yes — except when code is inserted as an image.

Do I need Markdown for conversion?

No. Markdown is optional but useful when working with documentation pipelines.

Can I export the generated document as a PDF file?

Yes. When saving the document, simply specify PDF as the output format in the Document.SaveToFile() method.

Get a Free License

To fully experience the capabilities of Spire.Doc for Python without any evaluation limitations, you can request a 30-day trial license.

Tutorial on How to Export List to Excel Without Interop in C#

Exporting list data to Excel with C# is a common requirement in modern .NET applications. Whether you are building a desktop application, a web system, or a background service, developers often need to convert in-memory collections—especially List<T>—into well-structured Excel files that users can download, analyze, or share.

This tutorial demonstrates how to export a list of objects to Excel in C# without using Excel Interop, using Spire.XLS for .NET. The solution is fully compatible with .NET Core and modern .NET versions, works with typical business data models, and does not require Microsoft Excel to be installed.

Table of Contents


Why Export a List to Excel in C# Without Interop?

Exporting list data to Excel is a practical way to present structured information in a familiar and widely accepted format. In real-world applications, this requirement commonly appears in scenarios such as:

  • Generating operational or financial reports
  • Allowing users to download query results from web applications
  • Sharing structured data with non-technical stakeholders
  • Performing offline analysis or audits using Excel

Traditionally, many developers rely on Excel Interop to generate Excel files. While Interop can work in certain desktop environments, it also introduces several limitations:

  • Microsoft Excel must be installed on the machine
  • It is not recommended for server-side or ASP.NET Core applications
  • It adds unnecessary dependencies for simple export tasks

As a result, exporting Excel files without Interop has become the preferred approach for modern .NET applications. Libraries such as Spire.XLS for .NET provide a clean, reliable, and server-friendly way to export a List<T> directly to Excel—without requiring Microsoft Office.


Export a List of Objects to Excel in C#

In most real-world applications, data is stored as a list of business objects rather than simple values. This section focuses on exporting a List<T> that represents a realistic reporting scenario, using a reusable and Interop-free approach.

Prerequisites

Before exporting a list to Excel, make sure Spire.XLS for .NET is installed in your project.

You can install it via NuGet:

Install-Package Spire.XLS

Once installed, you can start exporting List<T> data to Excel without any additional configuration.

Core Export Workflow

The overall process of exporting a list of objects to Excel can be summarized as follows:

  1. Prepare business-ready data in a List<T>
  2. Create an Excel workbook and worksheet
  3. Generate column headers dynamically from object properties
  4. Write list data into worksheet rows
  5. Save the Excel file

The following example demonstrates the complete implementation.

Complete Example: Export List to Excel

using Spire.Xls;
using System;
using System.Collections.Generic;
using System.Reflection;

public class OrderReport
{
    public int OrderId { get; set; }
    public string CustomerName { get; set; }
    public DateTime OrderDate { get; set; }
    public decimal TotalAmount { get; set; }
    public string Status { get; set; }
}

class Program
{
    static void Main()
    {
        // Prepare sample business data
        List<OrderReport> orders = new List<OrderReport>
        {
            new OrderReport { OrderId = 1001, CustomerName = "Alice", OrderDate = DateTime.Today.AddDays(-2), TotalAmount = 1200.50m, Status = "Completed" },
            new OrderReport { OrderId = 1002, CustomerName = "Bob", OrderDate = DateTime.Today.AddDays(-1), TotalAmount = 850.00m, Status = "Pending" },
            new OrderReport { OrderId = 1003, CustomerName = "Charlie", OrderDate = DateTime.Today, TotalAmount = 430.75m, Status = "Cancelled" }
        };

        // Create workbook and worksheet
        Workbook workbook = new Workbook();
        Worksheet sheet = workbook.Worksheets[0];

        // Read object properties dynamically
        PropertyInfo[] properties = typeof(OrderReport).GetProperties();

        // Write column headers
        for (int i = 0; i < properties.Length; i++)
        {
            sheet.Range[1, i + 1].Text = properties[i].Name;
        }

        // Write data rows
        for (int row = 0; row < orders.Count; row++)
        {
            for (int col = 0; col < properties.Length; col++)
            {
                object value = properties[col].GetValue(orders[row]);
                sheet.Range[row + 2, col + 1].Value2 = value;
            }
        }

        // Save Excel file
        workbook.SaveToFile("OrderReport.xlsx", ExcelVersion.Version2016);
    }
}

Below is a preview of the generated Excel file:

Simple List to Excel Exporting Using Spire.XLS for .NET in C#

Technical Notes and Implementation Details

  • An Excel file is created by instantiating Workbook, with the first worksheet accessed via workbook.Worksheets[0]
  • Column headers are generated dynamically using reflection (Type.GetProperties) to avoid hardcoded mappings
  • Header cells are written using Range.Text, ensuring clear string output in the first row
  • Object values are written row by row using Range.Value2 to preserve native Excel data types
  • The final Excel document is generated with Workbook.SaveToFile, without requiring Microsoft Excel or Interop

This pattern is ideal for building reusable export utilities and report-generation modules.

In scenarios where data is retrieved as a DataTable instead of a List, Spire.XLS also provides an efficient export approach. Refer to How to Export a DataTable to Excel in C# for detailed instructions.


Formatting the Exported Excel Worksheet

Beyond basic data export, Spire.XLS for .NET allows you to apply formatting to improve readability and usability of the generated Excel file.

Common formatting tasks include:

  • Styling header rows
  • Formatting dates and numeric values
  • Adjusting column widths automatically
  • Highlighting key fields

Example: Apply Basic Formatting

using System.Drawing;

// Format header row
CellStyle headerStyle = workbook.Styles.Add("HeaderStyle");
headerStyle.Font.FontName = "Arial";
headerStyle.Font.Size = 12f;
headerStyle.Font.IsBold = true;
headerStyle.Color = Color.LightGray;  // Set cell background color
headerStyle.HorizontalAlignment = HorizontalAlignType.Center;

sheet.Range[1, 1, 1, sheet.LastColumn].Style = headerStyle;

// Format date and amount columns
sheet.Range[2, 3, orders.Count + 1, 3].NumberFormat = "yyyy-mm-dd";
sheet.Range[2, 4, orders.Count + 1, 4].NumberFormat = "#,##0.00";

// Auto-fit row height and column width
sheet.AllocatedRange.AutoFitRows();
sheet.AllocatedRange.AutoFitColumns();

Below is a preview of the formatted Excel sheet:

Excel Sheet Formatted in C# Using Spire.XLS for .NET

Applying formatting makes the exported Excel file more professional and suitable for direct business use.

For more advanced worksheet formatting—such as styles, merged cells, conditional formatting, and formulas—see How to Create and Format Excel Worksheets in C#.


.NET Core and Server-Side Compatibility

Spire.XLS for .NET is fully compatible with .NET Core and modern .NET versions, making it suitable for:

  • ASP.NET Core web applications
  • Web APIs
  • Cloud and containerized environments
  • Background services and scheduled jobs

Because it does not rely on Excel Interop, the export logic is safe to use in server-side and production environments.

If you are working in an ASP.NET Core or Web API project, this guide shows how to generate and format Excel files and return them to the client: Export Excel Files in ASP.NET Core Using C#.


Conclusion

Exporting a list to Excel in C# does not have to rely on Excel Interop. With Spire.XLS for .NET, you can efficiently convert a List<T> into a well-structured and formatted Excel file that works seamlessly across .NET Framework and .NET Core environments.

By adopting an Interop-free approach, you reduce deployment complexity, improve application stability, and gain greater flexibility when exporting business data.

Whether you need to export complex reports or simple lists, Spire.XLS provides a reliable and scalable solution for modern C# applications. For evaluation purposes or to remove trial limitations, a 30-day temporary license is available.


Frequently Asked Questions

Q1. Can this approach export large lists efficiently?

Yes. Spire.XLS for .NET is designed for server-side usage and can handle large List datasets efficiently. For very large exports, batching or streaming strategies can further improve performance.

Q2. Does this solution require Microsoft Excel to be installed?

No. Spire.XLS for .NET works independently of Microsoft Excel and does not rely on Excel Interop, making it suitable for server and cloud environments.

Q3. Can I customize column headers or formats?

Yes. Column headers can be customized manually, and cell formats such as dates, numbers, and styles can be applied programmatically. For advanced formatting scenarios, refer to the C# Excel formatting guide.

Q4. Is this compatible with ASP.NET Core and Web APIs?

Yes. The export logic works seamlessly in ASP.NET Core applications, Web APIs, background services, and other server-side .NET environments.

page 43