[GH-ISSUE #506] Feature Request: Textboxes #392

Open
opened 2026-05-05 12:14:33 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @kruftindustries on GitHub (Jan 12, 2026).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/506

Originally assigned to: @jmcnamara on GitHub.

Insert text boxes into worksheets with configurable size, position, and scaling options.

API Changes:

New struct in drawing.h:
typedef struct lxw_textbox_options {
uint32_t width; /* Width in pixels (default 192) */
uint32_t height; /* Height in pixels (default 120) */
int32_t x_offset; /* X offset from cell in pixels */
int32_t y_offset; /* Y offset from cell in pixels */
double x_scale; /* X scale (default 1.0) */
double y_scale; /* Y scale (default 1.0) */
uint8_t object_position; /* Anchor position */
const char *description; /* Alt text description */
} lxw_textbox_options;

New functions:
lxw_error worksheet_insert_textbox(lxw_worksheet *worksheet,
lxw_row_t row, lxw_col_t col,
const char *text);

lxw_error worksheet_insert_textbox_opt(lxw_worksheet *worksheet,
lxw_row_t row, lxw_col_t col,
const char *text,
lxw_textbox_options *options);

Code Example:
#include "xlsxwriter.h"

int main() {
lxw_workbook *workbook = workbook_new("textbox.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

/* Simple textbox */
worksheet_insert_textbox(worksheet, 1, 1, "Hello World!");

/* Textbox with custom size */
lxw_textbox_options options = {
.width = 300,
.height = 150,
.x_offset = 10,
.y_offset = 10
};
worksheet_insert_textbox_opt(worksheet, 8, 1, "Custom textbox", &options);

return workbook_close(workbook);
}

Image
Originally created by @kruftindustries on GitHub (Jan 12, 2026). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/506 Originally assigned to: @jmcnamara on GitHub. ### Insert text boxes into worksheets with configurable size, position, and scaling options. **API Changes:** **New struct in** drawing.h: `typedef struct lxw_textbox_options {` ` uint32_t width; /* Width in pixels (default 192) */` ` uint32_t height; /* Height in pixels (default 120) */` ` int32_t x_offset; /* X offset from cell in pixels */` ` int32_t y_offset; /* Y offset from cell in pixels */` ` double x_scale; /* X scale (default 1.0) */` ` double y_scale; /* Y scale (default 1.0) */` ` uint8_t object_position; /* Anchor position */` ` const char *description; /* Alt text description */` `} lxw_textbox_options;` **New functions:** `lxw_error worksheet_insert_textbox(lxw_worksheet *worksheet,` ` lxw_row_t row, lxw_col_t col,` ` const char *text);` `lxw_error worksheet_insert_textbox_opt(lxw_worksheet *worksheet,` ` lxw_row_t row, lxw_col_t col,` ` const char *text,` ` lxw_textbox_options *options);` **Code Example:** `#include "xlsxwriter.h"` `int main() {` ` lxw_workbook *workbook = workbook_new("textbox.xlsx");` ` lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);` ` /* Simple textbox */` ` worksheet_insert_textbox(worksheet, 1, 1, "Hello World!");` ` /* Textbox with custom size */` ` lxw_textbox_options options = {` ` .width = 300,` ` .height = 150,` ` .x_offset = 10,` ` .y_offset = 10` ` };` ` worksheet_insert_textbox_opt(worksheet, 8, 1, "Custom textbox", &options);` ` return workbook_close(workbook);` `}` <img width="321" height="201" alt="Image" src="https://github.com/user-attachments/assets/82f635a5-3731-493c-bc5a-89e149f323a3" />
gitea-mirror added the
feature request
medium term
labels 2026-05-05 12:14:33 -06:00
Author
Owner

@jmcnamara commented on GitHub (Jan 12, 2026):

This is a somewhat useful feature. I would probably make this a medium term priority.

<!-- gh-comment-id:3737781508 --> @jmcnamara commented on GitHub (Jan 12, 2026): This is a somewhat useful feature. I would probably make this a medium term priority.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#392
No description provided.