{"id":75,"date":"2026-02-21T17:01:20","date_gmt":"2026-02-21T09:01:20","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=75"},"modified":"2026-01-17T10:25:56","modified_gmt":"2026-01-17T10:25:56","slug":"how-to-set-line-properties-using-xlwings-arrows","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-set-line-properties-using-xlwings-arrows\/","title":{"rendered":"How To Set Line Properties Using xlwings? &#8211; Arrows"},"content":{"rendered":"<h2>Method<\/h2>\n<p>You can set the line&#8217;s color using the `ForeColor` property of the `LineFormat` object. The color can be set using various methods, including RGB, theme colors, and color schemes.<\/p>\n<p>\u00a0<\/p>\n<p>You can set the line style using the `DashStyle` property of the `LineFormat` object. The available line styles are:<\/p>\n<p>\u00a0<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p>Name<\/p>\n<\/td>\n<td>\n<p>Value<\/p>\n<\/td>\n<td>\n<p>Description<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineDash<\/p>\n<\/td>\n<td>\n<p>4<\/p>\n<\/td>\n<td>\n<p>Dashed line<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineDashDot<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<td>\n<p>Dash-dot line<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineDashDotDot<\/p>\n<\/td>\n<td>\n<p>6<\/p>\n<\/td>\n<td>\n<p>Dash-dot-dot line<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineDashStyleMixed<\/p>\n<\/td>\n<td>\n<p>-2<\/p>\n<\/td>\n<td>\n<p>Not supported<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineLongDash<\/p>\n<\/td>\n<td>\n<p>7<\/p>\n<\/td>\n<td>\n<p>Long dashed line<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineLongDashDot<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<td>\n<p>Long dash-dot line<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineRoundDot<\/p>\n<\/td>\n<td>\n<p>3<\/p>\n<\/td>\n<td>\n<p>Round dotted line<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineSolid<\/p>\n<\/td>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>Solid line<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoLineSquareDot<\/p>\n<\/td>\n<td>\n<p>2<\/p>\n<\/td>\n<td>\n<p>Square dotted line<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00a0<\/p>\n<p>You can set the line width using the `Weight` property. This is a single value that determines the thickness of the line.<\/p>\n<p>\u00a0<\/p>\n<p>shp=sht.api.Shapes.AddLine(80, 50, 200, 300)\u00a0\u00a0\u00a0 #Create a line segment Shape object<\/p>\n<p>lf=shp.Line\u00a0\u00a0\u00a0 #Get the line shape object<\/p>\n<p>lf.Weight=2\u00a0\u00a0\u00a0 #Line width<\/p>\n<p>lf.BeginArrowheadLength=1\u00a0\u00a0\u00a0 #Arrow length at the start point<\/p>\n<p>lf.BeginArrowheadStyle=6\u00a0\u00a0\u00a0 #Arrow style at the start point<\/p>\n<p>lf.BeginArrowheadWidth=1\u00a0\u00a0\u00a0 #Arrow width at the start point<\/p>\n<p>lf.EndArrowheadLength=3\u00a0\u00a0\u00a0 #Arrow length at the endpoint<\/p>\n<p>lf.EndArrowheadStyle=2\u00a0\u00a0\u00a0 #Arrow style at the endpoint<\/p>\n<p>lf.EndArrowheadWidth=3\u00a0\u00a0\u00a0 #Arrow width at the endpoint<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Line properties - Arrow\n\nimport xlwings as xw    #Import xlwings package\n\napp=xw.App()\nbk=app.books.active   #Get the active workbook\nsht=bk.sheets.active    #Get the active worksheet\n\nshp=sht.api.Shapes.AddLine(80, 50, 200, 300)    #Create a line segment Shape object\nlf=shp.Line    #Get the line shape object\nlf.Weight=2    #Line width\nlf.BeginArrowheadLength=1    #Arrow length at the start point\nlf.BeginArrowheadStyle=6    #Arrow style at the start point\nlf.BeginArrowheadWidth=1    #Arrow width at the start point\nlf.EndArrowheadLength=3    #Arrow length at the endpoint\nlf.EndArrowheadStyle=2    #Arrow style at the endpoint\nlf.EndArrowheadWidth=3    #Arrow width at the endpoint\n\n#bk.save()\n#bk.close()\n#app.kill()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"779\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-3.png\" alt=\"Set Line Properties Using xlwings? - Arrows\" class=\"wp-image-423\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-3.png 779w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-3-300x186.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-3-768x475.png 768w\" sizes=\"auto, (max-width: 779px) 100vw, 779px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Method<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":3,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":425,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions\/425"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}