excel2pdf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 5 Imported by: 0

README

excel2pdf

convert xlsx file to pdf

Documentation

Overview

Package excel2pdf use excelize lib to read excel and gofpdf lib to write pdf. one sheet in excel will be one page in pdf.

Index

Constants

View Source
const (
	BorderTypeLeft   = "left"
	BorderTypeRight  = "right"
	BorderTypeTop    = "top"
	BorderTypeBottom = "bottom"
)
View Source
const (
	ElementTypeLine = "line"
	ElementTypeText = "text"
)
View Source
const (
	ElementAlignLeft   = "left"
	ElementAlignCenter = "center"
	ElementAlignRight  = "right"
)
View Source
const (
	VerticalAlignTop    = "top"
	VerticalAlignMiddle = "center"
	VerticalAlignBottom = "bottom"
)

Variables

This section is empty.

Functions

func ConvertColWidthToPixels

func ConvertColWidthToPixels(width float64) float64

func ConvertRowHeightToPixels

func ConvertRowHeightToPixels(height float64) float64

func CreatePdfElement

func CreatePdfElement(pdf *gopdf.GoPdf, cell string) error

func DrawBorder

func DrawBorder(row, col int, border *excelize.Border, rowPos, colPos *[]float64, pdf *gopdf.GoPdf, lineMap *map[string]bool)

func DrawPdfElement

func DrawPdfElement(pdf *gopdf.GoPdf, element *PdfElement)

func DrawPdfLine

func DrawPdfLine(pdf *gopdf.GoPdf, element *PdfElement)

func DrawPdfText

func DrawPdfText(pdf *gopdf.GoPdf, element *PdfElement)

func DrawSheetBorder

func DrawSheetBorder(fe *excelize.File, sheetName string, maxCol, maxRow int, rowPos, colPos *[]float64, pdf *gopdf.GoPdf)

func DrawSheetContent

func DrawSheetContent(fe *excelize.File, sheetName string, maxCol, maxRow int, rowPos, colPos *[]float64, pdf *gopdf.GoPdf)

func DrawText

func DrawText(startRow, startCol, endRow, endCol int, text string, rowPos, colPos *[]float64, pdf *gopdf.GoPdf, style *excelize.Style)

func Excel2Pdf

func Excel2Pdf(fe *excelize.File, pdf *gopdf.GoPdf) error

func GetCellPos

func GetCellPos(fe *excelize.File, sheetName string, maxCol, maxRow int) (*[]float64, *[]float64)

func GetEndAxis

func GetEndAxis(mergedCells []excelize.MergeCell, row, col int) (int, int)

func GetXPos

func GetXPos(line *PdfLine, horizontalAlign string, xPos, boxWidth float64) float64

func GetYPos

func GetYPos(pdfLines []PdfLine, verticalAlign string, yPos, boxHeight float64) float64

func IsMergedCell

func IsMergedCell(mergedCells []excelize.MergeCell, row, col int) bool

func ProcessSheet

func ProcessSheet(fe *excelize.File, sheetName string, pdf *gopdf.GoPdf) error

Types

type ElementColor

type ElementColor struct {
	R uint8 `json:"r,omitempty"`
	G uint8 `json:"g,omitempty"`
	B uint8 `json:"b,omitempty"`
}

type PdfElement

type PdfElement struct {
	Type             string        `json:"type,omitempty"`
	Font             *TextFont     `json:"font,omitempty"`
	Color            *ElementColor `json:"color,omitempty"`
	Rect             [4]float64    `json:"rect,omitempty"`
	Content          string        `json:"content,omitempty"`
	Width            float64       `json:"width,omitempty"`
	LineHeight       float64       `json:"lineHeight,omitempty"`
	WordSpace        float64       `json:"wordSpace,omitempty"`
	MaxContentLength int           `json:"maxContentLength,omitempty"`
	VerticalAlign    string        `json:"verticalAlign,omitempty"`
	HorizontalAlign  string        `json:"horizontalAlign,omitempty"`
	Padding          float64       `json:"padding,omitempty"`
}

type PdfLine

type PdfLine struct {
	Width   float64
	Height  float64
	Content string
}

func GetPdfLines

func GetPdfLines(pdf *gopdf.GoPdf, lines []string, lineHeight, xPos, yPos, boxWidth, wordSpace float64) []PdfLine

type TextFont

type TextFont struct {
	Size   float64 `json:"size,omitempty"`
	Style  string  `json:"style,omitempty"`
	Family string  `json:"family,omitempty"`
}

Jump to

Keyboard shortcuts

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