Change Cells Alignment and Keep Existing Formatting with Golang via C++

Possible Usage Scenarios

Sometimes, you want to change the alignment of multiple cells but also want to keep existing formatting. Aspose.Cells allows you to do it using the GetAlignments() property. If you set it to true, changes in alignment will take place; otherwise, they will not. Please note that the StyleFlag object is passed as a parameter to the ApplyStyle(const Style& style, const StyleFlag& flag) method, which actually applies the formatting to a range of cells.

Change Cells Alignment and Keep Existing Formatting

The following sample code loads the sample Excel file, creates the range, and center‑aligns it horizontally and vertically while keeping the existing formatting intact. The following screenshot compares the sample Excel file and the output Excel file, showing that all existing formatting of the cells is the same, except that the cells are now center‑aligned horizontally and vertically.

todo:image_alt_text

Sample Code