Importing *cell-formatting* information from excel file into R

跟風遠走 提交于 2019-12-08 21:48:14

问题


I have been given excel files (.xlsx) where the format of the cell is relevant information which I need to capture. The key formatting of interest are (1) cell color and (2) border (left + right, full box or absent).

Is it possible to read this into R?


回答1:


This is a very old question but still comes up in searches so I think it is useful to point people toward the tidyxl package.

tidyxl::xlsx_cells() reads an Excel spreadsheet in as a data frame where each row represents a single cell of the spreadsheet, with its address (e.g. A1), contents, and properties.

tidyxl::xlsx_formats() returns a nested list of all the different cell formats in the Excel spreadsheet.

The local_format_id column in the data frame returned by xlsx_cells() allows you to look up the formatting information for each cell in the list returned by xlsx_formats().

More information is included in the tidyxl package vignette.




回答2:


I've been really happy with the Python openpyxl project. Perhaps you can manipulate (preprocess) the xlsx in python to be digestable by R (perhaps CSV or XLS).

http://openpyxl.readthedocs.org/en/latest/index.html#tutorial

http://openpyxl.readthedocs.org/en/latest/usage.html#read-an-existing-workbook

There's an XLS import in Quick R:

http://www.statmethods.net/input/importingdata.html



来源:https://stackoverflow.com/questions/17816984/importing-cell-formatting-information-from-excel-file-into-r

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