FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour crear archivo en excel con imagenes
Posts: 467
Joined: Fri Dec 09, 2005 12:41 AM
crear archivo en excel con imagenes
Posted: Thu May 12, 2016 02:17 AM

Buenas noches, una consulta

Yo he estado creando in infome en Excel usando la clase TXls , ahora necesito ponerne unas imagenes en cieras secciones del reporte

Es posible pegar una imagen que la tengo en un archivo "C:\mis fotos\miproducto1.jpg" dentro de un rango de celdas C1:F15

o debere de usar otra clase, (esto es para Office 2010 en adelante, y los reprtes son extensos)

Les agradecere sus comentarios ,

Muchas gracias

Lubin

Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM
Re: crear archivo en excel con imagenes
Posted: Thu May 12, 2016 04:37 AM
Hola Lubin
Echale un ojo a esto:

Code (fw): Select all Collapse
//---------------------------
/*FORMATOS EXCEL
// Line styles
#define xlContinuous 1
#define xlDash -4115
#define xlDashDot 4
#define xlDashDotDot 5
#define xlDot -4118
#define xlDouble -4119
#define xlSlantDashDot 13
#define xlLineStyleNone -4142


// Border positions
#define xlEdgeLeft 7
#define xlEdgeTop 8
#define xlEdgeBottom 9
#define xlEdgeRight 10

oExcel := CreateObject( "Excel.Application" )
oExcel:WorkBooks:Add()
oAS := oExcel:ActiveSheet()
oAs:Range( "C10" ):Value := "Marco"
oAs:Range( "C10" ):Borders( xlEdgeTop ):LineStyle := xlContinuous

oHoja:Rows( 2 ):Bold := .T.

oHoja:Cells( 1, 4 ):Value := AMPAarra[2][3][1][13]

oHoja:Cells( 2, 1 ):AddComment()
oHoja:Cells( 2, 1 ):Text := "la data, fechita"

oHoja:Columns( 1 ):Set( "NumberFormat", "#,##0" )

oHoja:Columns( (nContador + 1 ) ):NumberFormat := "#.##0"

oHoja:Columns( (nContador + 1 ) ):NumberFormat := Lower( Set( _SET_DATEFORMAT ) )
oHoja:Columns( (nContador + 1 ) ):HorizontalAlignment := - 4152 //xlRight
oHoja:Cells( nFound, 3 ):HorizontalAlignment := - 4108 //Centrat
oHoja:Columns( (nContador + 1 ) ):Set( "NumberFormat", "@" )

oHoja:Cells( nFound, nCol ):Borders():LineStyle := 1
oHoja:Cells( nFound, nCol ):Borders( 8 ):LineStyle := 1

oHoja:Cells( nLinea, 3 ):AddComment()
oHoja:Cells( nLinea, 3 ):Text( AllTrim(oTdbfFamili:Obsefact) )

oHoja:Columns( 1 ):ColumnWidth := 6
oHoja:Columns( 2 ):ColumnWidth := 12
oHoja:Columns( 3 ):ColumnWidth := 10.5

oHoja:Cells( nLinea + 2, 8 ):NumberFormat := "#.##0,00"

oHoja:Cells( nLinea, 4 ):Italic := .T.


oHoja:Name := "Arial" // ESPECIFICA TIPO DE LETRA PARA TODA LA HOJA
oHoja:Size := 12 // ESPECIFICA TAMANO DE LETRA PARA TODA LA HOJA
oHoja:Cells( 1, 1 ):Size := 16 // DETERMINA TAMAÑO DE LETRA A USAR EN UNA CELDA
oHoja:Cells( 1, 1 ):Bold := .t. // PONE EN NEGRITAS VALOR DE UNA CELDA
oHoja:Cells( 1, 1 ):ColorIndex := 5 // COLOR PRE-ESTABLECIDO DE EXCEL PARA EL CONTENIDO DE LA CELDA
oHoja:Cells( 3, 2 ):Color := RGB(255,0,0) // COLOR DEL CONTENIDO DE LA CELDA
oHoja:Cells( 1, 4 ):ColorIndex := 16 // COLOR PRE-ESTABLECIDO DE EXCEL PARA LA CELDA(relleno)
oHoja:Cells( 3, 2 ):Color := RGB(200,160,35) // COLOR DE LA CELDA(relleno)
oHoja:Cells( 3, 1 ):NumberFormat := "$ ###,##0.00" // FORMATEAR CELDA NUMERICA

/*
//--------------------------- imagenes en excel
oHoja:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .t., .f., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA
oHoja:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .t., .t., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA
oHoja:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .f., .t., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA
oHoja:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .f., .f., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL DA ERROR QUE NO ENTIENDO
//------------------------------

METHOD FormatRange( cRange , cFont , nSize , lBold , lItalic , nAlign , nFore , nBack , nStyle , cFormat , lAutoFit )
  LOCAL oRange

  oRange := ::Range( cRange )

  IIF( cFont == Nil  , , oRange:Name := cFont )
  IIF( nSize == Nil  , , oRange:Size := nSize )
  IIF( lBold == Nil  , , oRange:Bold := lBold )
  IIF( lItalic == Nil, , oRange:Italic := lItalic )
  IIF( nFore == Nil  , , oRange:Color := nFore )
  IIF( nBack == Nil  , , oRange:Color := nBack )
  IIF( cFormat == Nil, , oRange:Set("NumberFormat",cFormat) )
  IIF( nStyle == Nil , , oRange:Borders():LineStyle  := nStyle )
  IIF( nAlign == Nil , , oRange:Set("HorizontalAlignment",Alltrim(Str(nAlign))) )
  IIF( lAutoFit == Nil , , oRange:AutoFit() )

RETURN ( Nil )
Posts: 467
Joined: Fri Dec 09, 2005 12:41 AM
Re: crear archivo en excel con imagenes
Posted: Thu May 12, 2016 07:12 PM

Hola Willy

Por lo que veo es usando una clase diferente a TXLS, o es la misma clase ??

de todas maneras lo veo interesante

GRACIASS !!!

Lubin

Continue the discussion