R can't manage “General” formatted cells when reading libreoffice generated xls

江枫思渺然 提交于 2019-12-12 02:05:45

问题


I switched to libreoffice for my spreadsheets, but I noticed an error when importing an xls file modified with libreoffice inside R using the gdata package's read.xls() function. If a column is formatted as General, then once in R the cells display General instead of the right value.

To fix it I need to format every column to the proper format (number, text, etc), which i'd prefer to avoid since general better manage formatting (eg. automatically display the right number of significant digits).

Any better solution?

SOLVED:

After suggestion by RockScience I tried openxlsx:read.xlsx() and it works perfectly. Is even faster and less error prone than gdata:read.xls()!


回答1:


I have also noticed that gdata::read.xls doesn't evaluate the formula, but instead just imports what is displayed in excel. So for instance if a formula returns 1.0002 but in excel the display is limited to 2 digits, gdata::read.xls will only import 1.00

I have looked at several ways of importing xls data into R:

As you see gnumeric::read.gnumeric.sheet does evaluate the formula, so I suggest you try this (but it needs access to the gnumeric command line which is not available easily on Windows)

since recently there is also a new package http://cran.r-project.org/web/packages/openxlsx/index.html which seems very promissing.



来源:https://stackoverflow.com/questions/28148580/r-cant-manage-general-formatted-cells-when-reading-libreoffice-generated-xls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!