UmyaSpreadsheet.VmlDrawing (umya_spreadsheet_ex v0.7.0)

View Source

Functions for working with VML (Vector Markup Language) drawings in Excel files.

VML is a legacy format used in Excel for shapes, comments, and embedded objects. This module allows you to create and manipulate VML shapes in Excel files.

Examples

iex> {:ok, spreadsheet} = UmyaSpreadsheet.new()
iex> UmyaSpreadsheet.VmlDrawing.create_shape(spreadsheet, "Sheet1", "shape1")
:ok
iex> UmyaSpreadsheet.VmlDrawing.set_shape_style(spreadsheet, "Sheet1", "shape1", "position:absolute;left:100pt;top:150pt;width:200pt;height:100pt")
:ok

Summary

Functions

Creates a new VML shape in the specified worksheet.

Gets the fill color of a VML shape.

Gets whether a VML shape is filled.

Gets the stroke (outline) color of a VML shape.

Gets the stroke (outline) weight/thickness of a VML shape.

Gets whether a VML shape has a stroke (outline).

Gets the CSS style of a VML shape.

Sets the stroke (outline) color of a VML shape.

Sets the stroke (outline) weight/thickness of a VML shape.

Sets whether a VML shape has a stroke (outline).

Sets the CSS style for a VML shape.

Functions

create_shape(spreadsheet, sheet_name, shape_id)

@spec create_shape(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  :ok | {:error, String.t()}

Creates a new VML shape in the specified worksheet.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • :ok on success
  • {:error, reason} on failure

get_shape_fill_color(spreadsheet, sheet_name, shape_id)

@spec get_shape_fill_color(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Gets the fill color of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • {:ok, fill_color} on success where fill_color is a color string (e.g. "#FF0000")
  • {:error, reason} on failure

get_shape_filled(spreadsheet, sheet_name, shape_id)

@spec get_shape_filled(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, boolean()} | {:error, String.t()}

Gets whether a VML shape is filled.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • {:ok, filled} on success where filled is a boolean
  • {:error, reason} on failure

get_shape_stroke_color(spreadsheet, sheet_name, shape_id)

@spec get_shape_stroke_color(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Gets the stroke (outline) color of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • {:ok, stroke_color} on success where stroke_color is a color string (e.g. "#0000FF")
  • {:error, reason} on failure

get_shape_stroke_weight(spreadsheet, sheet_name, shape_id)

@spec get_shape_stroke_weight(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Gets the stroke (outline) weight/thickness of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • {:ok, stroke_weight} on success where stroke_weight is a string (e.g. "2pt")
  • {:error, reason} on failure

get_shape_stroked(spreadsheet, sheet_name, shape_id)

@spec get_shape_stroked(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, boolean()} | {:error, String.t()}

Gets whether a VML shape has a stroke (outline).

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • {:ok, stroked} on success where stroked is a boolean
  • {:error, reason} on failure

get_shape_style(spreadsheet, sheet_name, shape_id)

@spec get_shape_style(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Gets the CSS style of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • {:ok, style} on success where style is a CSS style string
  • {:error, reason} on failure

get_shape_type(spreadsheet, sheet_name, shape_id)

@spec get_shape_type(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Gets the type of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape

Returns

  • {:ok, shape_type} on success where shape_type is the type (e.g. "rect", "oval", etc.)
  • {:error, reason} on failure

set_shape_fill_color(spreadsheet, sheet_name, shape_id, fill_color)

@spec set_shape_fill_color(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  :ok | {:error, String.t()}

Sets the fill color of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape
  • fill_color - The fill color (e.g. "#FF0000" for red)

Returns

  • :ok on success
  • {:error, reason} on failure

set_shape_filled(spreadsheet, sheet_name, shape_id, filled)

@spec set_shape_filled(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  boolean()
) ::
  :ok | {:error, String.t()}

Sets whether a VML shape is filled.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape
  • filled - Whether the shape should be filled (boolean)

Returns

  • :ok on success
  • {:error, reason} on failure

set_shape_stroke_color(spreadsheet, sheet_name, shape_id, stroke_color)

@spec set_shape_stroke_color(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  :ok | {:error, String.t()}

Sets the stroke (outline) color of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape
  • stroke_color - The stroke color (e.g. "#0000FF" for blue)

Returns

  • :ok on success
  • {:error, reason} on failure

set_shape_stroke_weight(spreadsheet, sheet_name, shape_id, stroke_weight)

@spec set_shape_stroke_weight(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  :ok | {:error, String.t()}

Sets the stroke (outline) weight/thickness of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape
  • stroke_weight - The stroke weight (e.g. "2pt")

Returns

  • :ok on success
  • {:error, reason} on failure

set_shape_stroked(spreadsheet, sheet_name, shape_id, stroked)

@spec set_shape_stroked(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  boolean()
) ::
  :ok | {:error, String.t()}

Sets whether a VML shape has a stroke (outline).

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape
  • stroked - Whether the shape should have a stroke (boolean)

Returns

  • :ok on success
  • {:error, reason} on failure

set_shape_style(spreadsheet, sheet_name, shape_id, style)

@spec set_shape_style(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  :ok | {:error, String.t()}

Sets the CSS style for a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape
  • style - CSS style string (e.g. "position:absolute;left:100pt;top:150pt;width:200pt;height:100pt")

Returns

  • :ok on success
  • {:error, reason} on failure

set_shape_type(spreadsheet, sheet_name, shape_id, shape_type)

@spec set_shape_type(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  :ok | {:error, String.t()}

Sets the type of a VML shape.

Parameters

  • spreadsheet - A spreadsheet struct
  • sheet_name - The name of the worksheet
  • shape_id - Unique identifier for the shape
  • shape_type - The shape type (e.g. "rect", "oval", "line", etc.)

Returns

  • :ok on success
  • {:error, reason} on failure

Shape Types

Common shape types include:

  • "rect" - Rectangle
  • "oval" - Oval or circle
  • "line" - Line
  • "polyline" - Polyline
  • "roundrect" - Rounded rectangle
  • "arc" - Arc