MCPcopy Create free account
hub / github.com/plandem/xlsx

github.com/plandem/xlsx @v1.0.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.4 ↗ · + Follow
1,012 symbols 3,656 edges 188 files ⚖ MIT 554 documented · 55% 88 cross-repo links updated 5y agov1.0.4 · 2019-11-02★ 17712 open issues

Browse by type

Functions 811 Types & classes 201
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Xlsx2Go

Build Status Code Coverage Go Report Card GoDoc License FOSSA Status Donate

package main

import (
    "github.com/plandem/xlsx"
    "github.com/plandem/xlsx/format/conditional"
    "github.com/plandem/xlsx/format/conditional/rule"
    "github.com/plandem/xlsx/format/styles"
)

func main() {
    xl := xlsx.New()
    defer xl.Close()

    //create a new sheet
    sheet := xl.AddSheet("The first sheet")

    //access by ref
    cell := sheet.CellByRef("A2")

    //set value
    cell.SetValue("Easy Peasy")

    //set cool styles
    cell.SetStyles(styles.New(
        styles.Font.Bold,
        styles.Font.Color("#ff0000"),
        styles.Fill.Type(styles.PatternTypeSolid),
        styles.Fill.Color("#ffff00"),
        styles.Border.Color("#009000"),
        styles.Border.Type(styles.BorderStyleMedium),
    ))

    //add comment
    cell.SetComment("No Comment!")

    //add hyperlink
    sheet.CellByRef("A4").SetValueWithHyperlink("wikipedia", "http://google.com")

    //merge cells
    sheet.RangeByRef("A6:A7").Merge()
    sheet.CellByRef("A6").SetValue("merged cell")

    //iterating
    for iRow := 1; iRow < 7; iRow++ {
        //access by indexes
        cell := sheet.Cell(1, iRow)
        cell.SetValue(iRow)
    }

    //add conditional formatting
    sheet.AddConditional(conditional.New(
        conditional.AddRule(
            rule.Value.Between(1, 3, styles.New(
                styles.Font.Bold,
                styles.Font.Color("#ff0000"),
            )),
        ),
        conditional.AddRule(
            rule.IconSet.Type(rule.IconSetType3Arrows),
        ),
    ), "B2:B7")

    xl.SaveAs("./foo.xlsx")
}

Documentation

Roadmap

  • [ ] sheet: copy
  • [ ] sheet: custom filters
  • [x] sheet: streaming
  • [x] merged cells: merge/split for ranges, cols, rows
  • [x] hyperlinks: for cells, ranges, cols, rows
  • [x] range: copy
  • [x] row: copy
  • [x] col: copy
  • [x] cell: comments
  • [ ] cell: formulas
  • [x] cell: typed getter/setter for values
  • [x] other: conditional formatting
  • [x] other: rich texts
  • [ ] other: drawing
  • [ ] other: more optimization
  • [ ] other: more tests

Contribution

  • To prevent mess, sources have strict separation of markup and functionality. Document that describes OOXML is quite huge (about 6K pages), but the same time - functionality is not.
  • All markup resides inside of 'ml' folders, only marshal/unmarshal is allowed here, no any functionality.
  • Not every 'ml object' has related 'functional object' and vice versa.
  • If you want some functionality, then wrap 'ml object' and do what you want.

OOXML edition

XML is compliant with part 1 of the 5th edition of the ECMA-376 Standard for Office Open XML

License

FOSSA Status

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 540
Function 271
Struct 137
TypeAlias 48
FuncType 10
Interface 6

Languages

Go100%

Modules by API surface

cell.go35 symbols
sheet.go32 symbols
sheet_info.go30 symbols
sheet_writestream.go28 symbols
sheet_readstream.go27 symbols
internal/ml/marshal.go27 symbols
format/styles/border.go27 symbols
sheet_readwrite.go21 symbols
types/hyperlink/hyperlink.go20 symbols
internal/ml/style_sheet.go20 symbols
internal/ml/worksheet.go19 symbols
range.go17 symbols

For agents

$ claude mcp add xlsx \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page