Gambas - armar archivo Calc(Openoffice) desde Gambas ?

 
Vista:

armar archivo Calc(Openoffice) desde Gambas ?

Publicado por horacio (11 intervenciones) el 17/03/2017 16:38:18
Estimados:

Se Puede armar un archivo Calc de Openoffice desde Gambas3 y editar sus celdas
Hay algun componente que habilitar?

si alguien lo probo desde ya muchas gracias

atte. Horacio Ferrer
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

armar archivo Calc(Openoffice) desde Gambas ?

Publicado por Horacio (11 intervenciones) el 26/06/2017 17:13:18
ya lo hice, si alguien lo necesita que lo pida
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
-1
Comentar
Imágen de perfil de Miguel
Val: 52
Oro
Ha mantenido su posición en Gambas (en relación al último mes)
Gráfica de Gambas

armar archivo Calc(Openoffice) desde Gambas ?

Publicado por Miguel (63 intervenciones) el 29/10/2017 16:50:19
Encontre esto por la red, seria cuestión de probarlo, la logica se ve bien

(http://libertadhack.blogspot.com/2011/02/gambas2-tableview-hoja-de-calculo-ods.html)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
'Gambas module file


PRIVATE pathOpendoc AS String = "/tmp/opendocgambas/" ' Ruta temporal donde se crearan los ficheros que componen el ODS
 
 
' Funcion que creará los ficheros que componen el ODS, y los empaquetará con el nombre de la variable pathODS
PUBLIC FUNCTION saveODS(controlx AS Object, pathODS AS String)

   

   DIM writer AS XmlWriter ' Creará los ficheros XML necesarios
   DIM filex AS File             ' Creará los ficheros de texto plano necesarios
   DIM iCount AS Integer     ' Índice para las filas del TableView
   DIM jCount AS Integer     ' Índice para las columnas del TableView
   

   ' Ejecutar función solo para GridViews o TableViews
   IF Object.Type(controlx) = "GridView" OR IF Object.Type(controlx) = "TableView" THEN
 
   TRY MKDIR pathOpendoc                                             ' Crear directorio temporal
   TRY MKDIR pathOpendoc &/ "Configurations2"   ' Crear otros directorios para el ODS
   TRY MKDIR pathOpendoc &/ "META-INF"
 
   TRY MKDIR pathOpendoc &/ "Thumbnails"
 
   ' Crear fichero mimetype
   filex = OPEN pathOpendoc &/ "mimetype" FOR INPUT CREATE 

       PRINT #filex, "application/vnd.oasis.opendocument.spreadsheet"; ' El ";" es para no insertar una terminación de línea
   CLOSE #filex
 
   ' Crear fichero manifest.xml
   writer = NEW XmlWriter

   WITH writer

   .Open(pathOpendoc &/ "META-INF/manifest.xml", TRUE, "UTF-8")

   .StartElement("manifest:manifest", ["xmlns:manifest", "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"])

       .StartElement("manifest:file-entry", ["manifest:media-type", "application/vnd.oasis.opendocument.spreadsheet", "manifest:version", "1.2", "manifest:full-path", "/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/statusbar/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/accelerator/current.xml"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/accelerator/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/floater/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/popupmenu/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/progressbar/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/menubar/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/toolbar/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/images/Bitmaps/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Configurations2/images/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", "application/vnd.sun.xml.ui.configuration", "manifest:full-path", "Configurations2/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", "text/xml", "manifest:full-path", "content.xml"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", "text/xml", "manifest:full-path", "styles.xml"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", "text/xml", "manifest:full-path", "meta.xml"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Thumbnails/thumbnail.png"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", " ", "manifest:full-path", "Thumbnails/"])

       .EndElement()

       .StartElement("manifest:file-entry", ["manifest:media-type", "text/xml", "manifest:full-path", "settings.xml"])

       .EndElement()

   .EndElement

   .EndDocument

   END WITH 

   

   ' Crear fichero content.xml. En este fichero se encuentra la data del TableView
   writer = NEW XmlWriter
 
   writer.Open(pathOpendoc &/ "content.xml", TRUE, "UTF-8")
 
   writer.StartElement("office:document-content")
 
     writer.Attribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0")
 
     writer.Attribute("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0")
 
     writer.Attribute("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0")
 
     writer.Attribute("xmlns:table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0")
 
     writer.Attribute("xmlns:number", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0")
 
     writer.Attribute("xmlns:chart", "urn:oasis:names:tc:opendocument:xmlns:chart:1.0")
 
     writer.Attribute("xmlns:form", "urn:oasis:names:tc:opendocument:xmlns:form:1.0")
 
     writer.Attribute("xmlns:oooc", "http://openoffice.org/2004/calc")
 
     writer.Attribute("xmlns:field", "urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0")
 
     writer.Attribute("xmlns:formx", "urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0")
 
     writer.Attribute("office:version", "1.2")
 
 
 
     writer.StartElement("office:body")
 
         writer.StartElement("office:spreadsheet")
 
         writer.StartElement("table:table", ["table:name", CStr(controlx.Name), "table:print", "false"])
 
         ' Si existen headers, también vaciarlos a la hoja de cálculo
         IF controlx.Header = GridView.Horizontal OR IF controlx.Header = GridView.Both THEN 

             writer.StartElement("table:table-row")

             FOR jCount = 0 TO controlx.Columns.Count - 1

                 writer.StartElement("table:table-cell", ["office:value-type", "string"])

                 writer.Element("text:p", controlx.Columns[jCount].Text)

                 writer.EndElement()

             NEXT 

             writer.EndElement()

         ENDIF 

         ' Vaciar la info de las celdas del TableView a la hoja de cálculo
         FOR iCount = 0 TO controlx.Rows.Count - 1 ' Recorremos las filas
             writer.StartElement("table:table-row")

             FOR jCount = 0 TO controlx.Columns.Count - 1   ' Recorremos las columnas
                 writer.StartElement("table:table-cell")
 
                 ' Indentificar si el dato es una string o un dato numerico
                 IF Str$(Val(controlx[iCount, jCount].Text)) = controlx[iCount, jCount].Text THEN 

                     writer.Attribute("office:value-type", "float")

                     writer.Attribute("office:value", controlx[iCount, jCount].Text)

                 ELSE 

                     writer.Attribute("office:value-type", "string")

                 ENDIF 

                 writer.Element("text:p", controlx[iCount, jCount].Text)

                 writer.EndElement()

             NEXT 

             writer.EndElement()

         NEXT 

         writer.EndElement()

     writer.EndElement()

   writer.EndElement()

   writer.EndDocument()



   ' Creamos un script bash para empaquetar los ficheros y directorios del ODS
   filex = OPEN pathOpendoc &/ "pckods" FOR INPUT CREATE
 
       PRINT #filex, "#!/bin/bash"
 
       PRINT #filex, "# Script creado con gambas, comprime ficheros para crear un documento ODS"
 
       PRINT #filex, "cd $(dirname $0)"
 
       PRINT #filex, "zip -r $1 Configurations2 META-INF Thumbnails content.xml mimetype"
 
   CLOSE #filex
 
   EXEC ["chmod", "+x", pathOpendoc &/ "pckods"] WAIT
 
   EXEC [pathOpendoc &/ "pckods", pathODS] WAIT ' Ejecutamos el script
   ELSE 

       ERROR "El control no es un GridView o TableView"

   ENDIF 


END
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar