Macros/Calc/py001
Outdated translations are marked like this.
TDF LibreOffice en español Document Liberation Project Blogs comunitarios Weblate Nextcloud Redmine Preguntas y respuestas Donar
Descripción
Copiar el contenido de una celda de un libro de Calc a otro. El libro de origen debe estar abierto.
Código Python
import uno
from com.sun.star.table.CellContentType import TEXT, VALUE
</div>
def copy_cell():
doc_source_name = 'source.ods'
sheet_source_name = 'source'
cell_source_name = 'A1'
desktop = XSCRIPTCONTEXT.getDesktop()
for doc_source in desktop.Components:
if doc_source.Title == doc_source_name:
break
cell_source = doc_source.Sheets[sheet_source_name][cell_source_name]
doc = XSCRIPTCONTEXT.getDocument()
cell = doc.CurrentController.ActiveSheet[cell_source_name]
if cell_source.Type == TEXT:
cell.String = cell_source.String
elif cell_source.Type == VALUE:
cell.Value = cell_source.Value
else:
cell.Formula = cell_source.Formula
return