[GH-ISSUE #344] worksheet_merge_range to display numerical data #277

Closed
opened 2026-05-05 12:05:26 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @sapomuyverde on GitHub (Jul 12, 2021).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/344

Originally assigned to: @jmcnamara on GitHub.

There is some restriction in which I cannot use worksheet_merge_range to combine columns and put numeric data?, I mean,
I have tried to put a numeric data: something like this:

worksheet_merge_range(worksheet, 6, 11, 6, 14, totalCtes, numberWithoutDecimalCenter)

and it didn't work, so I had to convert the variable to string and it worked, is it expected behavior?.

Regards,
Javier

Originally created by @sapomuyverde on GitHub (Jul 12, 2021). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/344 Originally assigned to: @jmcnamara on GitHub. There is some restriction in which I cannot use worksheet_merge_range to combine columns and put numeric data?, I mean, I have tried to put a numeric data: something like this: worksheet_merge_range(worksheet, 6, 11, 6, 14, totalCtes, numberWithoutDecimalCenter) and it didn't work, so I had to convert the variable to string and it worked, is it expected behavior?. Regards, Javier
gitea-mirror 2026-05-05 12:05:26 -06:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jmcnamara commented on GitHub (Jul 12, 2021):

and it didn't work, so I had to convert the variable to string and it worked, is it expected behavior?.

Yes.

From the docs for worksheet_merge_range:

The worksheet_merge_range() function writes a char* string using worksheet_write_string(). In order to write other data types, such as a number or a formula, you can overwrite the first cell with a call to one of the other write functions. The same Format should be used as was used in the merged range.

// First write a range with a blank string.
worksheet_merge_range (worksheet, 1, 1, 1, 3, "", format);
 
// Then overwrite the first cell with a number.
worksheet_write_number(worksheet, 1, 1, 123, format);
<!-- gh-comment-id:878540067 --> @jmcnamara commented on GitHub (Jul 12, 2021): > and it didn't work, so I had to convert the variable to string and it worked, is it expected behavior?. Yes. From the docs for [worksheet_merge_range](https://libxlsxwriter.github.io/worksheet_8h.html#ad5a2a09ec65c0f286b756235c7327225): > The `worksheet_merge_range()` function writes a char* string using `worksheet_write_string()`. In order to write other data types, such as a number or a formula, you can overwrite the first cell with a call to one of the other write functions. The same Format should be used as was used in the merged range. ```C // First write a range with a blank string. worksheet_merge_range (worksheet, 1, 1, 1, 3, "", format); // Then overwrite the first cell with a number. worksheet_write_number(worksheet, 1, 1, 123, format); ```
Author
Owner

@sapomuyverde commented on GitHub (Jul 12, 2021):

I didn't check the docs, thanks for clarifying.

<!-- gh-comment-id:878544528 --> @sapomuyverde commented on GitHub (Jul 12, 2021): I didn't check the docs, thanks for clarifying.
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#277
No description provided.