ycphs / openxlsx

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

I can't see the preview with iphone of a .xlsx file sent by email created with openxlsx #484

Closed AleTinaba93 closed 3 months ago

AleTinaba93 commented 3 months ago

i created a file in this way:

wb_test1 <- createWorkbook() addWorksheet(wb_test1, "KPI business") writeData(wb_test1, sheet = 1, x = "Liquidity * (ECB rate - 0.25)", startCol = 1, startRow = 2, colNames = FALSE) addStyle(wb_test1, sheet = 1, rows = 2, cols = 1, style = createStyle(halign = "center", valign = "center", textDecoration = "bold", wrapText = TRUE, border = "TopBottomLeftRight"), gridExpand = TRUE) saveWorkbook(wb_test1, "results/test1.xlsx", overwrite = TRUE)

i sent it by email and unfortunately if i try to open it with my iphone i can't see the preview because "is not supported" but i can opened it if i use excel app, but i need to be able to see alredy the preview. If i use write.xlsx to save file it works but i lose the whole formattation. Any solutions?

JanMarvin commented 3 months ago

Try openxlsx2. There are known issues with openxlsx.

AleTinaba93 commented 3 months ago

solved! It works

AleTinaba93 commented 3 months ago

unfortunately i can see the preview but losting all of customized formattation. Is there a way to see by using a smartphone the preview with the customized formattation without the excel app installed in the smartphone?

JanMarvin commented 3 months ago

You must be doing something wrong. If you can provide some code for a minimal example to reproduce what you are doing. Otherwise, it works fine with ms365 on my phone.

AleTinaba93 commented 3 months ago

pkgEnv$wb_revenues_arpu <- openxlsx2::wb_workbook() pkgEnv$wb_revenues_arpu$add_worksheet("test1") pkgEnv$wb_revenues_arpu$add_data("test1", x = pkgEnv$TAB, na.strings = "", start_col = 1, start_row = 1, col_names = TRUE) pkgEnv$wb_revenues_arpu$add_data("test1", x = "Tasso", na.strings = "", start_col = 1, start_row = 20, col_names = FALSE) pkgEnv$wb_revenues_arpu$add_data("test1", x = t(pkgEnv$tassi_chart$EBC), na.strings = "", start_col = 2, start_row = 20, col_names = FALSE) pkgEnv$wb_revenues_arpu$add_numfmt("test1", dims = "B20:N20", numfmt = "0.00%") pkgEnv$wb_revenues_arpu$set_col_widths("test1", cols = 1:pkgEnv$ncols, widths = 7.5) pkgEnv$wb_revenues_arpu$add_cell_style("test1", dims = "A1:P20", horizontal = "center", vertical = "center", wrap_text = 1) pkgEnv$wb_revenues_arpu$add_numfmt("test1", dims = "B2:P18", numfmt = "#,##0\u20AC") pkgEnv$wb_revenues_arpu$add_dxfs_style(name = "negStyle", font_color = openxlsx2::wb_color(hex = "#9C0006"), bgFill = openxlsx2::wb_color(hex = "#FFC7CE")) pkgEnv$wb_revenues_arpu$add_dxfs_style(name = "posStyle", font_color = openxlsx2::wb_color(hex = "#006100"), bgFill = openxlsx2::wb_color(hex = "#C6EFCE"))

openxlsx2::wb_save(pkgEnv$test1, "results/test1.xlsx", overwrite = TRUE)

JanMarvin commented 3 months ago

Please, something to reproduce ...

TAB <- mtcars[1:10, ]
# t(tassi_chart$EBC)
t_tassi_chart_EBC <- t(1:2)
ncols <- ncol(TAB)

wb_revenues_arpu <- openxlsx2::wb_workbook()
wb_revenues_arpu$add_worksheet("test1")
wb_revenues_arpu$add_data("test1", x = TAB, na.strings = "", start_col = 1,
                                 start_row = 1, col_names = TRUE)
wb_revenues_arpu$add_data("test1", x = "Tasso", na.strings = "", start_col = 1, start_row = 20, col_names = FALSE)
wb_revenues_arpu$add_data("test1", x = t_tassi_chart_EBC, na.strings = "", start_col = 2,
                                 start_row = 20, col_names = FALSE)
wb_revenues_arpu$add_numfmt("test1", dims = "B20:N20", numfmt = "0.00%")
wb_revenues_arpu$set_col_widths("test1", cols = 1:ncols, widths = 7.5)
wb_revenues_arpu$add_cell_style("test1", dims = "A1:P20", horizontal = "center", vertical = "center", wrap_text = 1)
wb_revenues_arpu$add_numfmt("test1", dims = "B2:P18", numfmt = "#,##0\u20AC")
wb_revenues_arpu$add_dxfs_style(name = "negStyle", font_color = openxlsx2::wb_color(hex = "#9C0006"),
                                       bgFill = openxlsx2::wb_color(hex = "#FFC7CE"))
wb_revenues_arpu$add_dxfs_style(name = "posStyle", font_color = openxlsx2::wb_color(hex = "#006100"),
                                       bgFill = openxlsx2::wb_color(hex = "#C6EFCE"))
wb_revenues_arpu$save("~/Documents/test.xlsx")

IMG_1825

Works fine. Looks the same on Mac and iPhone

AleTinaba93 commented 3 months ago

yes but you opened it by using excel app, instead i mean just the preview in which you see it just in reading mode so without using office app or excel app

JanMarvin commented 3 months ago

Do you mean the thumbnail here as in the following screenshot? If so, that's probably a limitation by numbers or whatever application iOS uses to create the thumbnail.

Open folder Documents jpeg