informax Posted February 23, 2022 Report Share Posted February 23, 2022 Troquei a versão do FileXLS para que meus módulos Funcionem Corretamente no Windows 10 e as Fórmulas não aceitam as variáveis do Harbour. Só não dão erro se elas forem declaradas como Públicas, mas não efetuam Nenhum Cálculo e as Células permanecem em BRANCO. Alguém pode me ajudar ??? Quote Link to comment Share on other sites More sharing options...
kapiaba Posted February 23, 2022 Report Share Posted February 23, 2022 Usou este? http://forums.fivetechsupport.com/viewtopic.php?f=6&t=39231&p=234126&hilit=FileXLS&sid=38303d0a58c43525e335a2385ce11a20#p234126 Regards, saludos. Quote Link to comment Share on other sites More sharing options...
informax Posted February 24, 2022 Author Report Share Posted February 24, 2022 Boa tarde amigo Kapi. Foi esse link que postou respondendo ao outra pergunta minha, ou seja, é o Link que mostra outro Link que direciona para a Página "Fivewin Contribuitions". Quote Link to comment Share on other sites More sharing options...
rochinha Posted March 3, 2022 Report Share Posted March 3, 2022 Amigunhos, informax Veja se meu código te dá alguma luz. Function XLSTabela() LOCAL oExcel, oHoja LOCAL nRow := 1, nCol M->NUM_TEMP := STRZERO(RANDOM(9999),4) M->DBF_TEMP := cPathDados+"\PN"+M->NUM_TEMP+".DB$" M->NTX_TEMP := cPathDados+"\PN"+M->NUM_TEMP+".CD$" CursorWait() oExcel := TOleAuto():New( "Excel.Application" ) oExcel:WorkBooks:Add() oHoja := oExcel:Get( "ActiveSheet" ) nRows := oHoja:UsedRange:Rows:Count() nCols := oHoja:UsedRange:Columns:Count() oHoja:PageSetup:Orientation := 2 oHoja:PageSetup:PrintGridlines := .t. // Margens oHoja:PageSetup:LeftMargin := 0.25 oHoja:PageSetup:RightMargin := 0.25 oHoja:PageSetup:TopMargin := 0.25 oHoja:PageSetup:BottomMargin := 0.25 oHoja:PageSetup:HeaderMargin := 0.25 oHoja:PageSetup:FooterMargin := 0.25 // oExcel:WorkBooks:Add() // oSheet = oExcel:ActiveSheet // oSheet:Cells( 1, 1 ):Value = "This is the first page" // oSheet:Rows( 2 ):PageBreak = xlPageBreakManual // oSheet:Cells( 2, 1 ):Value = "This is the second page" // oExcel:Visible = .T. // Area de Impressao oHoja:PageSetup:PrintArea = "$A$1:$O$60" // Area de Impressao //oRange := oExcel:Range("A10:A10"):Select() //oHoja:HPageBreaks := oRange //oRange := oHoja:Cells(60,15):Select() //oHoja:HPageBreaks:Add( oHoja:Range("A60:o60") ) //oPageBreak:Add( oRange ) //oHoja:HPageBreaks:Add( oHoja:Cells( 60, 14 ):Select() ) //oHoja:VPageBreaks:Add( "" ) //oHoja:HPageBreaks:Add( "A60" ) //oHoja:VPageBreaks:Add( "O60" ) // Define nome para planilha //oHoja:= oExcel:sheets:item(1) oHoja:name:='Tabela de Precos' //oSheet:Range("A:A"):Set("ColumnWidth",32) // AJUSTA TAMAÑO UN RANGO A UN VALOR // Toda planilha oHoja:Cells:Font:Name := "Arial" oHoja:Cells:Font:Size := 8 dbSelectArea( "ESTOQUE" ) @ tableXLS SELECT descricao,valorvenda ; FROM estoque TO (DBF_TEMP) USE (DBF_TEMP) ALIAS tableXLS NEW INDEX ON descricao TO (NTX_TEMP) SET INDEX TO (NTX_TEMP) // Formatando o titulo oHoja:Cells( 1, 1 ):Value := CL_NOME oHoja:Cells( 1, 1 ):Font:Size := 24 oHoja:Cells( 1, 1 ):Font:Name := "Arial" oHoja:Range( "A1:O1" ):HorizontalAlignment := 7 oHoja:Cells( 1, 1 ):Select() nRow := 2 nCol := 1 DO WHILE .T. // EOF() if nRow = 2 //oSheet:Range("A:A"):Set("ColumnWidth",32) // AJUSTA TAMAÑO UN RANGO A UN VALOR // Colocando nomes nas colunas oHoja:Cells( nRow, nCol+0 ):Value := "DESCRICAO" oHoja:Cells( nRow, nCol+1 ):Value := "PRECO" oHoja:Cells( nRow, nCol+2 ):Value := "QT" // Formatando estilo oHoja:Cells( nRow, nCol+0 ):Font:Bold := .T. // :Font:Size / :Font:Color oHoja:Cells( nRow, nCol+1 ):Font:Bold := .T. oHoja:Cells( nRow, nCol+2 ):Font:Bold := .T. // Formatando tamanho oHoja:Cells( nRow, nCol+0 ):ColumnWidth := 22 oHoja:Cells( nRow, nCol+1 ):ColumnWidth := 6 oHoja:Cells( nRow, nCol+2 ):ColumnWidth := 5 oHoja:Cells( nRow, nCol+3 ):ColumnWidth := 0.25 // Formatando tamanho oHoja:Cells( nRow, nCol+0 ):Interior:ColorIndex := 6 oHoja:Cells( nRow, nCol+1 ):Interior:ColorIndex := 6 oHoja:Cells( nRow, nCol+2 ):Interior:ColorIndex := 6 // nRow := 3 endif // Formatando um campo oHoja:Cells( nRow, nCol+0 ):Value := descricao oHoja:Cells( nRow, nCol+1 ):NumberFormat := "##.##0,00" oHoja:Cells( nRow, nCol+1 ):Value := valorvenda // Calcula quantidade * valorvenda oHoja:Cells( nRow, nCol+3 ):NumberFormat := "##.##0,00" oHoja:Cells( nRow, nCol+3 ):Value := "="+chr(64+nCol+1)+alltrim(str(nRow))+"*"+chr(64+nCol+2)+alltrim(str(nRow)) // Somatoria dos subtotais //oHoja:Cells( nRow, nCol+1 ):NumberFormat := "##.##0,00" //oHoja:Cells( nRow, nCol+1 ):Value := "=soma("+chr(64+nCol+2)+"3:"+chr(64+nCol+2)+"57)" // oHoja:Cells( nRow, nCol+0 ):Font:Bold := .T. oHoja:Cells( nRow, nCol+1 ):Font:Bold := .T. // oHoja:Cells( nRow, nCol+2 ):Interior:ColorIndex := 6 // nRow := nRow + 1 if eof() exit endif SKIP ENDDO // oHoja:Cells( 59, 1 ):Value := "SUBTOTAL" oHoja:Cells( 59, 1 ):Font:Bold := .T. oHoja:Cells( 59, 1 ):Font:Size := 10 oHoja:Cells( 60, 1 ):NumberFormat := "####.##0,00" oHoja:Cells( 60, 1 ):Value := "=B58+F58+J58+N58" oHoja:Cells( 60, 1 ):Font:Italic := .T. oHoja:Cells( 60, 1 ):Font:Bold := .T. // oHoja:Cells( 59, 5 ):Value := "DESCONTO" oHoja:Cells( 59, 5 ):Font:Bold := .T. oHoja:Cells( 59, 5 ):Font:Size := 10 oHoja:Cells( 60, 5 ):NumberFormat := "####.##0,00" //oHoja:Cells( 60, 5 ):Value := "=B58+F58+J58+N58" oHoja:Cells( 60, 5 ):Font:Italic := .T. oHoja:Cells( 60, 5 ):Font:Bold := .T. // oHoja:Cells( 59, 9 ):Value := "TOTAL GERAL" oHoja:Cells( 59, 9 ):Font:Bold := .T. oHoja:Cells( 59, 9 ):Font:Size := 10 oHoja:Cells( 60, 9 ):NumberFormat := "####.##0,00" oHoja:Cells( 60, 9 ):Value := "=A60-(A60*(E60*0,01))" oHoja:Cells( 60, 9 ):Font:Italic := .T. oHoja:Cells( 60, 9 ):Font:Bold := .T. // dbSelectArea( "ESTOQUE" ) // oExcel:Visible := .T. //oHoja:PrintOut() // Funciona OK //oExcel:WorkBooks:SaveAs(cFilePath(GetModuleFileName(GetInstance()))+"\FABRICA.xls") oHoja:End() oExcel:End() // CursorArrow() RETURN Quote Link to comment Share on other sites More sharing options...
Andre Meneghetti Posted March 7, 2022 Report Share Posted March 7, 2022 Em 03/03/2022 at 04:04, rochinha disse: Amigunhos, informax Veja se meu código te dá alguma luz. Function XLSTabela() LOCAL oExcel, oHoja LOCAL nRow := 1, nCol M->NUM_TEMP := STRZERO(RANDOM(9999),4) M->DBF_TEMP := cPathDados+"\PN"+M->NUM_TEMP+".DB$" M->NTX_TEMP := cPathDados+"\PN"+M->NUM_TEMP+".CD$" CursorWait() oExcel := TOleAuto():New( "Excel.Application" ) oExcel:WorkBooks:Add() oHoja := oExcel:Get( "ActiveSheet" ) nRows := oHoja:UsedRange:Rows:Count() nCols := oHoja:UsedRange:Columns:Count() oHoja:PageSetup:Orientation := 2 oHoja:PageSetup:PrintGridlines := .t. // Margens oHoja:PageSetup:LeftMargin := 0.25 oHoja:PageSetup:RightMargin := 0.25 oHoja:PageSetup:TopMargin := 0.25 oHoja:PageSetup:BottomMargin := 0.25 oHoja:PageSetup:HeaderMargin := 0.25 oHoja:PageSetup:FooterMargin := 0.25 // oExcel:WorkBooks:Add() // oSheet = oExcel:ActiveSheet // oSheet:Cells( 1, 1 ):Value = "This is the first page" // oSheet:Rows( 2 ):PageBreak = xlPageBreakManual // oSheet:Cells( 2, 1 ):Value = "This is the second page" // oExcel:Visible = .T. // Area de Impressao oHoja:PageSetup:PrintArea = "$A$1:$O$60" // Area de Impressao //oRange := oExcel:Range("A10:A10"):Select() //oHoja:HPageBreaks := oRange //oRange := oHoja:Cells(60,15):Select() //oHoja:HPageBreaks:Add( oHoja:Range("A60:o60") ) //oPageBreak:Add( oRange ) //oHoja:HPageBreaks:Add( oHoja:Cells( 60, 14 ):Select() ) //oHoja:VPageBreaks:Add( "" ) //oHoja:HPageBreaks:Add( "A60" ) //oHoja:VPageBreaks:Add( "O60" ) // Define nome para planilha //oHoja:= oExcel:sheets:item(1) oHoja:name:='Tabela de Precos' //oSheet:Range("A:A"):Set("ColumnWidth",32) // AJUSTA TAMAÑO UN RANGO A UN VALOR // Toda planilha oHoja:Cells:Font:Name := "Arial" oHoja:Cells:Font:Size := 8 dbSelectArea( "ESTOQUE" ) @ tableXLS SELECT descricao,valorvenda ; FROM estoque TO (DBF_TEMP) USE (DBF_TEMP) ALIAS tableXLS NEW INDEX ON descricao TO (NTX_TEMP) SET INDEX TO (NTX_TEMP) // Formatando o titulo oHoja:Cells( 1, 1 ):Value := CL_NOME oHoja:Cells( 1, 1 ):Font:Size := 24 oHoja:Cells( 1, 1 ):Font:Name := "Arial" oHoja:Range( "A1:O1" ):HorizontalAlignment := 7 oHoja:Cells( 1, 1 ):Select() nRow := 2 nCol := 1 DO WHILE .T. // EOF() if nRow = 2 //oSheet:Range("A:A"):Set("ColumnWidth",32) // AJUSTA TAMAÑO UN RANGO A UN VALOR // Colocando nomes nas colunas oHoja:Cells( nRow, nCol+0 ):Value := "DESCRICAO" oHoja:Cells( nRow, nCol+1 ):Value := "PRECO" oHoja:Cells( nRow, nCol+2 ):Value := "QT" // Formatando estilo oHoja:Cells( nRow, nCol+0 ):Font:Bold := .T. // :Font:Size / :Font:Color oHoja:Cells( nRow, nCol+1 ):Font:Bold := .T. oHoja:Cells( nRow, nCol+2 ):Font:Bold := .T. // Formatando tamanho oHoja:Cells( nRow, nCol+0 ):ColumnWidth := 22 oHoja:Cells( nRow, nCol+1 ):ColumnWidth := 6 oHoja:Cells( nRow, nCol+2 ):ColumnWidth := 5 oHoja:Cells( nRow, nCol+3 ):ColumnWidth := 0.25 // Formatando tamanho oHoja:Cells( nRow, nCol+0 ):Interior:ColorIndex := 6 oHoja:Cells( nRow, nCol+1 ):Interior:ColorIndex := 6 oHoja:Cells( nRow, nCol+2 ):Interior:ColorIndex := 6 // nRow := 3 endif // Formatando um campo oHoja:Cells( nRow, nCol+0 ):Value := descricao oHoja:Cells( nRow, nCol+1 ):NumberFormat := "##.##0,00" oHoja:Cells( nRow, nCol+1 ):Value := valorvenda // Calcula quantidade * valorvenda oHoja:Cells( nRow, nCol+3 ):NumberFormat := "##.##0,00" oHoja:Cells( nRow, nCol+3 ):Value := "="+chr(64+nCol+1)+alltrim(str(nRow))+"*"+chr(64+nCol+2)+alltrim(str(nRow)) // Somatoria dos subtotais //oHoja:Cells( nRow, nCol+1 ):NumberFormat := "##.##0,00" //oHoja:Cells( nRow, nCol+1 ):Value := "=soma("+chr(64+nCol+2)+"3:"+chr(64+nCol+2)+"57)" // oHoja:Cells( nRow, nCol+0 ):Font:Bold := .T. oHoja:Cells( nRow, nCol+1 ):Font:Bold := .T. // oHoja:Cells( nRow, nCol+2 ):Interior:ColorIndex := 6 // nRow := nRow + 1 if eof() exit endif SKIP ENDDO // oHoja:Cells( 59, 1 ):Value := "SUBTOTAL" oHoja:Cells( 59, 1 ):Font:Bold := .T. oHoja:Cells( 59, 1 ):Font:Size := 10 oHoja:Cells( 60, 1 ):NumberFormat := "####.##0,00" oHoja:Cells( 60, 1 ):Value := "=B58+F58+J58+N58" oHoja:Cells( 60, 1 ):Font:Italic := .T. oHoja:Cells( 60, 1 ):Font:Bold := .T. // oHoja:Cells( 59, 5 ):Value := "DESCONTO" oHoja:Cells( 59, 5 ):Font:Bold := .T. oHoja:Cells( 59, 5 ):Font:Size := 10 oHoja:Cells( 60, 5 ):NumberFormat := "####.##0,00" //oHoja:Cells( 60, 5 ):Value := "=B58+F58+J58+N58" oHoja:Cells( 60, 5 ):Font:Italic := .T. oHoja:Cells( 60, 5 ):Font:Bold := .T. // oHoja:Cells( 59, 9 ):Value := "TOTAL GERAL" oHoja:Cells( 59, 9 ):Font:Bold := .T. oHoja:Cells( 59, 9 ):Font:Size := 10 oHoja:Cells( 60, 9 ):NumberFormat := "####.##0,00" oHoja:Cells( 60, 9 ):Value := "=A60-(A60*(E60*0,01))" oHoja:Cells( 60, 9 ):Font:Italic := .T. oHoja:Cells( 60, 9 ):Font:Bold := .T. // dbSelectArea( "ESTOQUE" ) // oExcel:Visible := .T. //oHoja:PrintOut() // Funciona OK //oExcel:WorkBooks:SaveAs(cFilePath(GetModuleFileName(GetInstance()))+"\FABRICA.xls") oHoja:End() oExcel:End() // CursorArrow() RETURN Muito interessante amigo Rochinha e testarei assim que possível. Muito obrigado. Quote Link to comment Share on other sites More sharing options...
rochinha Posted March 8, 2022 Report Share Posted March 8, 2022 Amiguinhos, Andre Meneghetti O codigo abaixo é somente um trecho que filtra alguns dados e campos para minimizar o peso de uso das tabelas. Nada impede de colocar suas filtragens som SET FILTER etc. @ tableXLS SELECT descricao,valorvenda ; FROM estoque TO (DBF_TEMP) USE (DBF_TEMP) ALIAS tableXLS NEW INDEX ON descricao TO (NTX_TEMP) SET INDEX TO (NTX_TEMP) // Formatando o titulo O resto é código normal. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.