crear archivo en excel con imagenes

crear archivo en excel con imagenes

Postby lubin » Thu May 12, 2016 2: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
User avatar
lubin
 
Posts: 439
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru

Re: crear archivo en excel con imagenes

Postby Willi Quintana » Thu May 12, 2016 4:37 am

Hola Lubin
Echale un ojo a esto:

Code: Select all  Expand view

//---------------------------
/*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 ):Font:Bold := .T.

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

oHoja:Cells( 2, 1 ):AddComment()
oHoja:Cells( 2, 1 ):Comment: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 ):Comment: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 ):Font:Italic := .T.


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

/*
//--------------------------- imagenes en excel
oHoja:Shapes:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .t., .f., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA
oHoja:Shapes:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .t., .t., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA
oHoja:Shapes:AddPicture( "RUTA DE LA IMAGEN\imagen.xxx", .f., .t., 100, 150, 80, 120 ) // AGREGA IMAGEN A EXCEL FUNCIONA
oHoja:Shapes: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 := ::oSheet:Range( cRange )

  IIF( cFont == Nil  , , oRange:Font:Name := cFont )
  IIF( nSize == Nil  , , oRange:Font:Size := nSize )
  IIF( lBold == Nil  , , oRange:Font:Bold := lBold )
  IIF( lItalic == Nil, , oRange:Font:Italic := lItalic )
  IIF( nFore == Nil  , , oRange:Font:Color := nFore )
  IIF( nBack == Nil  , , oRange:Interior: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:Columns:AutoFit() )

RETURN ( Nil )


User avatar
Willi Quintana
 
Posts: 1002
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: crear archivo en excel con imagenes

Postby lubin » Thu May 12, 2016 7: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
User avatar
lubin
 
Posts: 439
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 6 guests