0

I have created a shiny app where a user must be able to load and edit certain worksheets within an excel workbook, save it and re-open it for another process. I decided to use the openxlsx package to open and edit an excel workbook that has links and formulae. I believe the openxlsx package is good for editing workbooks without loss of data.

Well I am able to edit and save a file but when it comes to reading a particular sheet containing values back into r to do some analysis, the sheet/ dataframe in r contains zeros instead of the values I saved it with. I have searched for a solution but find nothing related.

I did notice that when I open the saved workbook outside of r, the values all appear to fine as they are treated as numeric values in excel. However, it seems the workbook is compressed because once I press save on excel, the file expands by about 2mb. Is this an openxlsx issue or is there another way to open a sheet of my saved workbook without losing information? Thanks in advance.

P.S My questions never get answered on stackoverflow. I assume it's because I'm not able to ask in a clear way. So if you need me to eleborat, please let me know.

I tried using read_excel:

read_excel(path = '2022-12-01.xlsx', sheet = 'data', range = "B14:AE66", col_names = F, col_types = 'numeric')

I also tried using openxlsx's readWorkbook:

readWorkbook('2022-12-01.xlsx', sheet = 'data', startRow = 14, cols = c(2:31), rows = c(14:66), colNames = F)

Note that my workbook was saved with styling particularly because excel could not recognize my values before but now that excel recognizes them, R doesn't lol.

Cebo_ SA
  • 1
  • 2
  • 2
    Welcome to SO, Cebo_SA! (A few months late, but ... I think I'm still the first ;-). Please make this question *reproducible*. This includes sample code you've attempted (a minimal but functional shiny app, for this question) and sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))` into a [code block]) that reproduces the "zeroes problem". Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Jul 14 '23 at 11:43
  • ^ This - that's why nobody answers your questions... – smartse Jul 14 '23 at 13:05

0 Answers0