Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

SaveAs whit atributes excel in cobol native

$
0
0

Good day, I come to your collaboration and knowledge. How can I give attributes when saving to excel?

 

This is the code, Chris I collaborated with the separation of the text in columns, thanks to the I could generate direct reports to excel

78 xlDelimited value 1.
01 ExcelObject object reference.
01 WorkBooksCollection object reference.
01 WorkBook object reference.
01 CellRange object reference.
01 theRange object reference.
01 ExcelFileFormat pic x(4) value "true".
01 SaveName pic x(256) value spaces.
01 NOMBRE PIC X(15) VALUE "TECNOLOGIA".
01 pausa pic x.
01 GUARDADO OBJECT REFERENCE.

LINKAGE SECTION.
01 AREA-LINK.
03 ARCHIVO-WS PIC X(90).

Procedure Division USING AREA-LINK.
*> Creo a Excel como un objeto y lo llamo
invoke MSExcel "new" returning ExcelObject

*> El objeto excel se hace visible en memoria
invoke ExcelObject "setVisible" using by value 1

*> Obtengo el numero de libros y pongo por def el numero uno
invoke ExcelObject "getWorkBooks"
returning WorkBooksCollection

*> Abro el archivo desde la ruta
invoke WorkbooksCollection "Open" using ARCHIVO-WS
returning Workbook
invoke ExcelObject "getRange"
*> Si cambio el rango desde A1 no me separa la ultima linea
using z"A2:A1000000"
returning CellRange
end-invoke
*> Aca separo por el delimitador el archivo y lo escribo en memo
invoke olesup "setNamedParameters" using by value 4
invoke CellRange "TextToColumns" using
by reference z"Destination"
by value cellrange
by reference z"DataType"
by value xlDelimited
by reference z"Other"
by value oletrue
by reference z"OtherChar"
"|"
* invoke CellRange "finalize" returning CellRange
*AUTOFID DE COLUMNAS
INVOKE ExcelObject "GetColumns" using z"A:IV"
returning theRange
* invoke theRange "select"
* invoke theRange "Copy"
* invoke theRange "PasteSpecial" using
* by value -4163
* by value -4142
invoke theRange "Autofit"
invoke theRange "finalize" returning theRange
invoke ExcelObject "getRange"
using z"A1:A2"
returning CellRange
end-invoke


*> Aca salgo de Excel, si quiero puedo guardarlo automaticamente
*> sin preguntarle al usuario. si comentariza el
*> "invoke ExcelObject "Quit"" Excel termina sin preguntar si
*> desea guardar
 *>Saves the file, but with TXT attributes of not Excel

invoke olesup "setNamedParameters" using by value 3 size 4
invoke WorkBook "SaveAs" using Z"Filename" SaveName
by reference z"XlFileFormat" z"xlWorkbookNormal"
end-invoke

*> Close the WorkBook, discarding the contents
* invoke WorkBook "Close" using by value 0

*> Finalize all objects
invoke theRange "finalize" returning theRange
invoke CellRange "finalize" returning CellRange
invoke WorkBook "finalize" returning WorkBook
invoke WorkBooksCollection "finalize"
returning WorkBooksCollection
end-invoke

*> Exit Excel
* invoke ExcelObject "Quit"
invoke ExcelObject "Finalize" returning ExcelObject
exit program


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>