Title: | Write Formatted Tables in Excel Workbooks |
Version: | 1.2.5 |
Date: | 2023-05-04 |
Author: | Jesus Maria RodrÃguez RodrÃguez |
Maintainer: | Jesus Maria Rodriguez Rodriguez <jesusmro@gmail.com> |
Description: | For writing tables with custom formats in a Excel file ready to be distributed. |
Depends: | R (≥ 3.2),openxlsx |
License: | GPL-3 |
LazyData: | true |
Encoding: | UTF-8 |
NeedsCompilation: | no |
Packaged: | 2023-05-04 16:50:16 UTC; Jesus |
Repository: | CRAN |
Date/Publication: | 2023-05-04 22:20:02 UTC |
Draw borders an area in an Excel sheet
Description
Draw borders an area in an Excel sheet, with the characteristics indicated in the parameters
Usage
bordear(wb, hoja, fila = 1, columna = 1, ancho = 1, alto = 1,
estilo = createStyle(border = "topleftbottomright",
borderStyle = "double", borderColour = "blue4"))
Arguments
wb |
An object of Workbook class |
hoja |
The name, if it is a text, or the position, if it is numeric, of the sheet |
fila |
The row of the upper-left corner of the area |
columna |
The column of the upper-left corner of the area |
ancho |
The number of cells in the width of the area |
alto |
The number of cells in the height of the area |
estilo |
The border style. It must be an object of class Style, and he border styles are used |
Details
Of the parameter estilo is used: border, borderColour and borderStyle. The last two can be vectors, in such a way that each feature is applied to the corresponding edge, according to the order established in border
See Also
createStyle
Examples
## Example
require(openxlsx)
wb=createWorkbook()
addWorksheet(wb,"Primera")
bordear(wb,"Primera",3,2,5,4)
##openXL(wb)
## Otro ejemplo
wb=createWorkbook()
addWorksheet(wb,"Primera")
bordear(wb,"Primera",3,2,5,4,
estilo=createStyle(border="bottomtop",borderColour=c("red","blue"),
borderStyle=c("double","thin")))
##openXL(wb)
Write a matrix or data.frame with styles in a sheet of a excel workbook
Description
Write a matrix or data.frame with format in a sheet of a excel workbook, In the position and styles indicated in the parameters
Usage
escribirTabla(tabla, wb=NULL,hoja=NULL,fichero=NULL,
limpiarFilas=TRUE,limpiarColumnas=TRUE,limpiarValores=NA,
cabecera = "", fuente = "", notas = "",
fila = 7, columna = 3, decimales = 1, porcentaje = FALSE,
cabecerasFila = TRUE, cabecerasColumna = TRUE,
cabeceraFilas="",cabeceraColumnas="",
anchoCabecera = 10,anchoDatos = 14,
escudo = NULL,posEscudo=c(1,1),
tamEscudo=c(2.7,4.5),unidadesEscudo="cm",
estilos=options("tablaxlsx.Estilos")[[1]],
bordes = c("TABLA","CABECERA","CABECERASFILA","CABECERASCOLUMNA","DATOS"),
estilosBordes = NULL)
Arguments
tabla |
The matrix, data.frame or ftable to write |
wb |
The Workbook. If NULL is created |
hoja |
The name o position of Worksheet. If it does not exist or is NULL is created |
fichero |
The name of a file where the Workbook is saved. If NULL it is not saved |
limpiarFilas |
If it is TRUE are deleted rows in which all values are in limpiarValores |
limpiarColumnas |
If it is TRUE are deleted columns in which all values are in limpiarValores |
limpiarValores |
Values used for cleaning |
cabecera |
A text to be written in the header of the table |
fuente |
A text that is written at the end of the table |
notas |
One or more texts to write after the |
fila |
The row of tht upper-left cell where the table will be written |
columna |
The column of tht upper-left cell where the table will be written |
decimales |
Number of decimal places that are written with the numerical data. It can be a vector, in which case it is applied successively to each column, recycling the values if necessary |
porcentaje |
If the data is given percentage format or not. It may be a vector, in which case it is applied successively to each column, recycling values if required |
cabecerasFila |
If you write or not the rows headers, which will be the names of the rows of the matrix or the corresponding elements of a ftable |
cabecerasColumna |
If you write or not the columns headers, which will be the names of the rows of the matrix or the corresponding elements of a ftable |
cabeceraFilas |
Text to write above the row's headers |
cabeceraColumnas |
Text to write above the row's headers |
anchoCabecera |
The width, in characters, of the columns of the row header |
anchoDatos |
The width, in characters, of the data columns |
escudo |
If it is NULL does not any figure, if it is a text is inserted the figure that is in the file |
posEscudo |
Position, row and column, of the figure, if escudo is not NULL |
tamEscudo |
A vector with Height and Width of the figure |
unidadesEscudo |
Units of the height of the image. By default "cm" |
estilos |
A list with the styles to apply to the various elements of the table. |
bordes |
A vector with the names of the elements in the table will be to surround with edges, the possible values are: CABECERA, CABECERASFILA, CABECERASCOLUMNA, DATOS, TABLA (the entire table) |
estilosBordes |
A list with the styles of the various edges. Each item will be called with one of the possible names on bordes. |
Details
Edges are drawn in the order: CABECERA,CABECERASFILA,CABECERASCOLUMNA,DATOS,TABLA
Value
If it have created a Workbook returns the Workbook created, otherwise returns a vector with the row and column of the lower-right cell of the table with notes and source in the worksheet and the lower-right cell of the table only.
See Also
createStyle
Examples
## Example 1
matriz=matrix(runif(20),4,5)
wb=createWorkbook()
hoja=addWorksheet(wb,"Prueba")
escribirTabla(matriz,wb,hoja,fila=4,columna=4)
if(interactive()) openXL(wb)
# Example 2
f1=ftable(mtcars[,c(2,8:11)],col.vars=3:4)
wb=escribirTabla(f1,estilos=estilosDGE,bordes=c("TABLA","DATOS"),
escudo=system.file("img/logoJMR.png",package="tablaxlsx"))
l1=escribirTabla(f1,wb,"otra",anchoCabecera=20,estilos=estilosDGE,bordes=c("TABLA","DATOS"),
escudo=system.file("img/logoJMR.png",package="tablaxlsx"),
posEscudo=c(2,2),tamEscudo=c(1,1))
if(interactive()) openXL(wb)
An example of styles for to use
Description
Styles's list of example
Usage
data("estilosDGE")
Format
Styles's list of example
Examples
data(estilosDGE)
An example of styles for to use
Description
Styles's list of example
Usage
data("estilosDGPYE")
Format
Styles's list of example
Examples
data(estilosDGPYE)
Reduce a matrix, ftable or data.frame
Description
Reduce the matrix, ftable o data.frame suppressing rows or columns whose elements are all equal to one of the values of valores.
Usage
reducir(x,valores=NA,filas=TRUE,columnas=TRUE)
Arguments
x |
Matrix, ftable or data.frame |
valores |
Vector values to compare |
filas |
If TRUE (default) the rows with all values in valores will be deleted |
columnas |
If TRUE (default) the columns with all values in valores will be deleted |
Value
Returns a matrix or data.frame without the rows o columns with all values equals to a value from the valores. If x is a ftable returns an array with two attributes, cabColumna and cabFila which contain an array of header rows and columns.
Write a matrix or data.frame with styles in a sheet of a excel workbook
Description
Puts the styles used by default in escribirTabla
Usage
tablaxlsx.estilos.set(estilos.defecto)
Arguments
estilos.defecto |
The list of styles to use by default in escribirTabla |
Details
Puts the list estilos.defecto in the tablaxlsx.Estilos option for use by default in escribirTabla.
See Also
escribirTabla, createStyle and estilosDGE
Show in excel a matrix or data.frame
Description
Show in excel a matrix or data.frame
Usage
verXL(tabla,...)
Arguments
tabla |
Matrix, data.frame or any object that can handle escribirTabla |
... |
parameters of escribirTabla |
Examples
## Example
## Not run:
verXL(iris,fila=1,columna=1)
## End(Not run)