{{ book.info }}
func (f *File) AddShape(sheet string, opts *Shape) error
根據給定的工作表名、儲存格坐標和樣式(包括偏移、縮放、拉伸、寬高比和列印屬性等)在指定儲存格添加圖形。例如,在名為 Sheet1
的工作表上添加文本框(矩形):
lineWidth := 1.2
err := f.AddShape("Sheet1",
&excelize.Shape{
Cell: "G6",
Type: "rect",
Line: excelize.ShapeLine{Color: "4286F4", Width: &lineWidth},
Fill: excelize.Fill{Color: []string{"8EB9FF"}},
Paragraph: []excelize.RichTextRun{
{
Text: "Rectangle Shape",
Font: &excelize.Font{
Bold: true,
Italic: true,
Family: "Times New Roman",
Size: 18,
Color: "777777",
Underline: "sng",
},
},
},
Width: 180,
Height: 40,
},
)
下面是 Excelize 所支援的所有圖形:
名稱 | 圖形 | 預覽 |
---|---|---|
accentBorderCallout1 | 標注:線形(帶外框和強調線) | |
accentBorderCallout2 | 標注:彎曲線形(帶外框和強調線) | |
accentBorderCallout3 | 標注:雙彎曲線形(帶外框和強調線) | |
accentCallout1 | 標注:線形(帶強調線) | |
accentCallout2 | 標注:彎曲線形(帶強調線) | |
accentCallout3 | 標注:雙彎曲線形(帶強調線) | |
actionButtonBackPrevious | 動作按鈕:後退或前一項 | |
actionButtonBeginning | 動作按鈕:轉到開頭 | |
actionButtonBlank | 動作按鈕:空白 | |
actionButtonDocument | 動作按鈕:文檔 | |
actionButtonEnd | 動作按鈕:轉到結尾 | |
actionButtonForwardNext | 動作按鈕:前進或下一項 | |
actionButtonHelp | 動作按鈕:幫助 | |
actionButtonHome | 動作按鈕:轉到主頁 | |
actionButtonInformation | 動作按鈕:獲取信息 | |
actionButtonMovie | 動作按鈕:視頻 | |
actionButtonReturn | 動作按鈕:上一張 | |
actionButtonSound | 動作按鈕:聲音 | |
arc | 曲線的弧圖形 | |
bentArrow | 箭頭:圓角右 | |
bentConnector2 | 彎曲的連接器 2 圖形 | |
bentConnector3 | 彎曲的連接器 3 圖形 | |
bentConnector4 | 彎曲的連接器 4 圖形 | |
bentConnector5 | 連接符:肘形 | |
bentUpArrow | 箭頭:直角上 | |
bevel | 矩形:稜台 | |
blockArc | 空心弧 | |
borderCallout1 | 標注:線形 | |
borderCallout2 | 標注:彎曲線形 | |
borderCallout3 | 標注:雙彎曲線形 | |
bracePair | 雙大括號 | |
bracketPair | 雙括號 | |
callout1 | 標注:線形(無外框) | |
callout2 | 標注:彎曲線形(無外框) | |
callout3 | 標注:雙彎曲線形(無外框) | |
can | 圓柱體 | |
chartPlus | 圖表加上圖形 | |
chartStar | 圖表的星形 | |
chartX | 圖表 X 圖形 | |
chevron | 箭頭:V 形 | |
chord | 弦形 | |
circularArrow | 箭頭:環形 | |
cloud | 雲形 | |
cloudCallout | 雲形標注 | |
corner | L 形 | |
cornerTabs | 角選項卡圖形 | |
cube | 立方體 | |
curvedConnector2 | 弧形 | |
curvedConnector3 | 鏈接符:曲線 | |
curvedConnector4 | 曲線的連接符 4 圖形 | |
curvedConnector5 | 曲線的連接符 5 圖形 | |
curvedDownArrow | 箭頭:上弧形 | |
curvedLeftArrow | 箭頭:右弧形 | |
curvedRightArrow | 箭頭:左弧形 | |
curvedUpArrow | 箭頭:下弧形 | |
decagon | 十邊形 | |
diagStripe | 斜紋 | |
diamond | 菱形 | |
dodecagon | 十二邊形 | |
donut | 圓:空心 | |
doubleWave | 雙波形 | |
downArrow | 箭頭:下 | |
downArrowCallout | 標注:下箭頭 | |
ellipse | 橢圓形 | |
ellipseRibbon | 帶形:前凸彎 | |
ellipseRibbon2 | 帶形:上凸彎 | |
flowChartAlternateProcess | 流程圖:可選過程 | |
flowChartCollate | 流程圖:對照 | |
flowChartConnector | 流程圖:接點 | |
flowChartDecision | 流程圖:決策 | |
flowChartDelay | 流程圖:延期 | |
flowChartDisplay | 流程圖:顯示 | |
flowChartDocument | 流程圖:文檔 | |
flowChartExtract | 流程圖:摘錄 | |
flowChartInputOutput | 流程圖:數據 | |
flowChartInternalStorage | 流程圖:內部貯存 | |
flowChartMagneticDisk | 流程圖:磁盤 | |
flowChartMagneticDrum | 流程圖:直接訪問存儲器 | |
flowChartMagneticTape | 流程圖:順序訪問存儲器 | |
flowChartManualInput | 流程圖:手動輸入 | |
flowChartManualOperation | 流程圖:手動操作 | |
flowChartMerge | 流程圖:合併 | |
flowChartMultidocument | 流程圖:多文檔 | |
flowChartOfflineStorage | 流程圖:離頁存儲 | |
flowChartOffpageConnector | 流程圖:離頁連接符 | |
flowChartOnlineStorage | 流程圖:存儲數據 | |
flowChartOr | 流程圖:或者 | |
flowChartPredefinedProcess | 流程圖:預定義過程 | |
flowChartPreparation | 流程圖:準備 | |
flowChartProcess | 流程圖:過程 | |
flowChartPunchedCard | 流程圖:卡片 | |
flowChartPunchedTape | 流程圖:資料帶 | |
flowChartSort | 流程圖:排序 | |
flowChartSummingJunction | 流程圖:匯總連接 | |
flowChartTerminator | 流程圖:終止 | |
foldedCorner | 矩形:折角 | |
frame | 圖文框 | |
funnel | 漏斗形 | |
gear6 | 齒輪 6 圖形 | |
gear9 | 齒輪 9 圖形 | |
halfFrame | 半閉框 | |
heart | 心形 | |
heptagon | 七邊形 | |
hexagon | 六邊形 | |
homePlate | 箭頭:五邊形 | |
horizontalScroll | 卷形:水平 | |
irregularSeal1 | 爆炸形 1 | |
irregularSeal2 | 爆炸形 2 | |
leftArrow | 箭頭:左 | |
leftArrowCallout | 標注:左箭頭 | |
leftBrace | 左大括號 | |
leftBracket | 左中括號 | |
leftCircularArrow | 左側的環形箭頭圖形 | |
leftRightArrow | 箭頭:左右 | |
leftRightArrowCallout | 標注:左右箭頭 | |
leftRightCircularArrow | 左右環形箭頭圖形 | |
leftRightRibbon | 左右功能區圖形 | |
leftRightUpArrow | 箭頭:丁字 | |
leftUpArrow | 箭頭:直角雙向 | |
lightningBolt | 閃電形 | |
line | 直線 | |
lineInv | 圖形:反向直線 | |
mathDivide | 除號 | |
mathEqual | 等號 | |
mathMinus | 減號 | |
mathMultiply | 乘號 | |
mathNotEqual | 不等號 | |
mathPlus | 加號 | |
moon | 新月形 | |
nonIsoscelesTrapezoid | 梯形 | |
noSmoking | 禁止符 | |
notchedRightArrow | 箭頭:燕尾形 | |
octagon | 八邊形 | |
parallelogram | 平行四邊形 | |
pentagon | 五邊形 | |
pie | 不完整圓 | |
pieWedge | 餅圖楔入圖形 | |
plaque | 缺角矩形 | |
plaqueTabs | 板選項卡圖形 | |
plus | 十字形 | |
quadArrow | 箭頭:十字 | |
quadArrowCallout | 標注:十字箭頭 | |
rect | 矩形 | |
ribbon | 帶形:前凸 | |
ribbon2 | 帶形:上凸 | |
rightArrow | 箭頭:右 | |
rightArrowCallout | 批注:右箭頭 | |
rightBrace | 右中括號 | |
rightBracket | 右大括號 | |
round1Rect | 矩形:單圓角 | |
round2DiagRect | 矩形:對角圓角 | |
round2SameRect | 矩形:圓頂角 | |
roundRect | 矩形:圓角 | |
rtTriangle | 直角三角形 | |
smileyFace | 笑臉 | |
snip1Rect | 矩形:減去單角 | |
snip2DiagRect | 矩形:減去對角 | |
snip2SameRect | 矩形:減去左右頂角 | |
snipRoundRect | 矩形:一個圓頂角,減去另一個頂角 | |
squareTabs | 方形選項卡圖形 | |
star10 | 星形:十角 | |
star12 | 星形:十二角 | |
star16 | 星形:十六角 | |
star24 | 星形:二十四角 | |
star32 | 星形:三十二角 | |
star4 | 星形:四角 | |
star5 | 星形:五角 | |
star6 | 星形:六角 | |
star7 | 星形:七角 | |
star8 | 星形:八角 | |
straightConnector1 | 直線連接符 1 圖形 | |
stripedRightArrow | 箭頭:虛尾 | |
sun | 太陽形 | |
swooshArrow | Swoosh 箭頭圖形 | |
teardrop | 淚滴形 | |
trapezoid | 梯形 | |
triangle | 等腰三角形 | |
upArrow | 箭頭:上 | |
upArrowCallout | 批注:上箭頭 | |
upDownArrow | 箭頭:上下 | |
upDownArrowCallout | 批注:上下箭頭 | |
uturnArrow | 箭頭:手杖形 | |
verticalScroll | 卷形:垂直 | |
wave | 波形 | |
wedgeEllipseCallout | 對話氣泡:橢圓形 | |
wedgeRectCallout | 對話氣泡:矩形 | |
wedgeRoundRectCallout | 對話氣泡:圓角矩形 |