-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set charts background and add text wrap to box shapes #1786
Labels
enhancement
New feature or request
Comments
melf-xyzh
added a commit
to melf-xyzh/excelize
that referenced
this issue
Jan 21, 2024
10 tasks
xuri
pushed a commit
that referenced
this issue
Jan 22, 2024
Thanks for your issue.
For example: package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
for idx, row := range [][]interface{}{
{nil, "Apple", "Orange", "Pear"}, {"Small", 2, 3, 3},
{"Normal", 5, 2, 4}, {"Large", 6, 7, 8},
} {
cell, err := excelize.CoordinatesToCellName(1, idx+1)
if err != nil {
fmt.Println(err)
return
}
f.SetSheetRow("Sheet1", cell, &row)
}
if err := f.AddChart("Sheet1", "E1", &excelize.Chart{
Type: excelize.Line,
Series: []excelize.ChartSeries{
{
Name: "Sheet1!$A$2",
Categories: "Sheet1!$B$1:$D$1",
Values: "Sheet1!$B$2:$D$2",
},
{
Name: "Sheet1!$A$3",
Categories: "Sheet1!$B$1:$D$1",
Values: "Sheet1!$B$3:$D$3",
},
{
Name: "Sheet1!$A$4",
Categories: "Sheet1!$B$1:$D$1",
Values: "Sheet1!$B$4:$D$4",
Marker: excelize.ChartMarker{
// Specify solid fill for chart marker by Fill field
Fill: excelize.Fill{Type: "pattern", Color: []string{"777777"}, Pattern: 1},
},
}},
Title: []excelize.RichTextRun{
{
Text: "Line Chart",
},
},
// Specify transparent fill for chart area by Fill field,
// declare Type and Pattern, but without Color
Fill: excelize.Fill{Type: "pattern", Pattern: 1},
PlotArea: excelize.ChartPlotArea{
// Specify transparent fill for chart plot area by Fill field,
// declare Type and Pattern, but without Color
Fill: excelize.Fill{Type: "pattern", Pattern: 1},
},
}); err != nil {
fmt.Println(err)
return
}
// Add a rectangle shape with gray fill color and rich-text
if err := f.AddShape("Sheet1", &excelize.Shape{
Cell: "B7",
Type: "rect",
Paragraph: []excelize.RichTextRun{
{Text: "Rectangle", Font: &excelize.Font{Color: "CD5C5C"}},
{Text: "Shape", Font: &excelize.Font{Bold: true, Color: "2980B9"}},
},
Fill: excelize.Fill{Type: "pattern", Color: []string{"DDDDDD"}, Pattern: 1},
Height: 50,
Width: 80,
}); err != nil {
fmt.Println(err)
return
}
// Save spreadsheet by the given path.
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe that you can edit the xml files associated with the Excel file (this is not a stable solution) but is it possible to add a feature to
The text was updated successfully, but these errors were encountered: