mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-25 13:48:53 +08:00
spreadsheet: fix drawing for Mac Excel
This commit is contained in:
parent
45fe2ad00c
commit
bb72680e01
@ -48,13 +48,18 @@ func main() {
|
||||
totalSeries.Values().SetReference(`'Sheet 1'!D2:D6`)
|
||||
|
||||
// the line chart accepts up to two axes
|
||||
lc.AddAxis(chart.AddCategoryAxis())
|
||||
lc.AddAxis(chart.AddValueAxis())
|
||||
ca := chart.AddCategoryAxis()
|
||||
va := chart.AddValueAxis()
|
||||
lc.AddAxis(ca)
|
||||
lc.AddAxis(va)
|
||||
|
||||
ca.SetCrosses(va)
|
||||
va.SetCrosses(ca)
|
||||
|
||||
// add a title and legend
|
||||
title := chart.AddTitle()
|
||||
title.SetText("Items Sold")
|
||||
chart.AddLegend()
|
||||
// title := chart.AddTitle()
|
||||
// title.SetText("Items Sold")
|
||||
// chart.AddLegend()
|
||||
|
||||
// and finally add the chart to the sheet
|
||||
sheet.SetDrawing(dwng)
|
||||
|
@ -34,11 +34,15 @@ func (d Drawing) InitializeDefaults() {
|
||||
// chart won't show up.
|
||||
d.x.TwoCellAnchor.From.Col = 5
|
||||
d.x.TwoCellAnchor.From.Row = 0
|
||||
// Mac Excel requires the offsets be present
|
||||
d.x.TwoCellAnchor.From.ColOff.ST_CoordinateUnqualified = gooxml.Int64(0)
|
||||
d.x.TwoCellAnchor.From.RowOff.ST_CoordinateUnqualified = gooxml.Int64(0)
|
||||
d.x.TwoCellAnchor.To.Col = 10
|
||||
d.x.TwoCellAnchor.To.Row = 20
|
||||
d.x.TwoCellAnchor.To.ColOff.ST_CoordinateUnqualified = gooxml.Int64(0)
|
||||
d.x.TwoCellAnchor.To.RowOff.ST_CoordinateUnqualified = gooxml.Int64(0)
|
||||
}
|
||||
|
||||
func (d Drawing) AddChart() Chart {
|
||||
chart := crt.NewChartSpace()
|
||||
d.wb.charts = append(d.wb.charts, chart)
|
||||
@ -64,6 +68,12 @@ func (d Drawing) AddChart() Chart {
|
||||
}
|
||||
d.x.TwoCellAnchor.Choice = &sd.EG_ObjectChoicesChoice{}
|
||||
d.x.TwoCellAnchor.Choice.GraphicFrame = sd.NewCT_GraphicalObjectFrame()
|
||||
|
||||
// required by Mac Excel
|
||||
d.x.TwoCellAnchor.Choice.GraphicFrame.NvGraphicFramePr = sd.NewCT_GraphicalObjectFrameNonVisual()
|
||||
d.x.TwoCellAnchor.Choice.GraphicFrame.NvGraphicFramePr.CNvPr.IdAttr = 2
|
||||
d.x.TwoCellAnchor.Choice.GraphicFrame.NvGraphicFramePr.CNvPr.NameAttr = "Chart"
|
||||
|
||||
d.x.TwoCellAnchor.Choice.GraphicFrame.Graphic = dml.NewGraphic()
|
||||
d.x.TwoCellAnchor.Choice.GraphicFrame.Graphic.GraphicData.UriAttr = "http://schemas.openxmlformats.org/drawingml/2006/chart"
|
||||
c := c.NewChart()
|
||||
|
Loading…
x
Reference in New Issue
Block a user