excel2pdf

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 9 Imported by: 0

README

excel2pdf

Converts an Excel file to PDF, compatible with both Windows and Linux. Uses either LibreOffice or Microsoft Excel, with LibreOffice given priority if installed.

var excelPath = `file.xlsx`

func main() {
    pdfFilePath,err := excel2pdf.ConvertExcelToPdf(excelPath)
	fmt.Println(pdfFilePath, err)
}

Documentation

Overview

Package excel2pdf converts Excel (.xlsx) files to PDF.

It supports Windows, Linux, and macOS. On Windows, LibreOffice is preferred if installed, with automatic fallback to Microsoft Excel. On Linux and macOS, LibreOffice is required.

All operations are protected by a mutex so that only one conversion or merge can run at a time. Callers that attempt a second concurrent operation will receive ErrExcel2PdfIsProcessing.

Example

pdfPath, err := excel2pdf.ConvertExcelToPdf("report.xlsx")
if err != nil {
	log.Fatal(err)
}
fmt.Println("PDF written to", pdfPath)

Index

Constants

This section is empty.

Variables

View Source
var ErrExcel2PdfIsProcessing = errors.New("a process is currently running using the resource")

ErrExcel2PdfIsProcessing is returned by ConvertExcelToPdf or CombinePdfs when another operation is already in progress.

View Source
var ErrLibreofficeNotInstalled = errors.New("LibreOffice is not installed")

ErrLibreofficeNotInstalled is returned on Linux and macOS when LibreOffice cannot be located on the system.

Functions

func CombinePdfs

func CombinePdfs(pdfFiles []string, outputPdfFile string) (pdfFile string, err error)

CombinePdfs merges one or more PDF files into a single PDF written to outputPdfFile and returns the output path.

Only one operation may run at a time. If another call is already in progress, ErrExcel2PdfIsProcessing is returned immediately.

func ConvertExcelToPdf

func ConvertExcelToPdf(excelFile string) (pdfFile string, err error)

ConvertExcelToPdf converts an Excel file to PDF and returns the path of the generated PDF file.

On Windows, LibreOffice is used when available; otherwise Microsoft Excel is used. On Linux and macOS, LibreOffice must be installed.

Only one conversion may run at a time. If another call is already in progress, ErrExcel2PdfIsProcessing is returned immediately.

Types

This section is empty.

Directories

Path Synopsis
Command example demonstrates batch conversion of Excel files to a single PDF.
Command example demonstrates batch conversion of Excel files to a single PDF.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL