ycphs / openxlsx

openxlsx - a fast way to read and write complex xslx files
https://ycphs.github.io/openxlsx/
Other
220 stars 74 forks source link

Chart in Excel does not show merged cells even after merging using openxlsx #408

Closed wspagnola closed 6 months ago

wspagnola commented 1 year ago

Hello,

I'm trying to export data into an excel file and create a file that looks this

column_chart_merged

I use this code to create a report and use the mergeCells function to merge ela and math into one cell

`` wb <- createWorkbook() addWorksheet(wb, "Report") writeData(wb, "Report", school_report, startCol = 1, startRow = 1, rowNames = FALSE)

mergeCells(wb, "Report", cols = 1, rows = 2:(length(grades)+1)) mergeCells(wb, "Report", cols = 1, rows = (length(grades)+2):(nrow(school_report)+1))

saveWorkbook(wb, file = paste0(path, "school_report.xlsx"), TRUE) `` However, when I create the save file and create a chart the subject in the x-axis appears unmerged even though the cells in the sheet are clearly merged. If I manually unmerge and re-merge the cells the chart appears the way I want it to.

column_chart_unmerged

I was wondering if there is something I can do in R to fix this or if this is excel issue.

JanMarvin commented 1 year ago

Just a guess: it might be because every merged cell still contains data. You could try to erase the duplicated cells and keep only a single cell value. mergeCell simply sets the XML string that tells excel to combine the cells. If you unmerge the cells you see a value in every cell.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 6 months ago

This issue was closed because it has been stalled for 7 days with no activity.