0% found this document useful (0 votes)
101 views

Exportar Excel

This document contains code for exporting accounting journal data from a database to an Excel spreadsheet file for a specified period. It retrieves the necessary company and period information from a web session. The code writes the header, column names, and line item data to the spreadsheet. It loops through the journal entries and writes the code, date, description, debit and credit amounts to the cells. Formulas are added to calculate totals. The file is saved, closed, and error handling is performed.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views

Exportar Excel

This document contains code for exporting accounting journal data from a database to an Excel spreadsheet file for a specified period. It retrieves the necessary company and period information from a web session. The code writes the header, column names, and line item data to the spreadsheet. It loops through the journal entries and writes the code, date, description, debit and credit amounts to the cells. Formulas are added to calculate totals. The file is saved, closed, and error handling is performed.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

&EmpreDes=&ApplicationWebSession.Get('EmpreDes') &EmpreGir=&ApplicationWebSession.Get('EmpreGir') &EmpreRuc=&ApplicationWebSession.Get('EmpreRuc') &cPeriAnio=&ApplicationWebSession.Get('PeriAnio') &cPeriId=&ApplicationWebSession.Get('PeriId') &PeriMes=&ApplicationWebSession.Get('PeriMes') &PeriNombreMes=&ApplicationWebSession.

Get('PeriNombreMes') &nomMes=&PeriNombreMes+" - "+&cPeriAnio // Exports the contents of a grid (using the selected order and filters) to an Excel file. &Random = Random() * 10000 &Filename = !"ExportarReporteLibroDiarioSimp_" + &Random.ToString().Trim() + !".xls" &ExcelDocument.Open(&Filename) Do 'CheckStatus' &ExcelDocument.Clear() &CellRow = 6 &FirstColumn = 1 //ENCABEZADO &ExcelDocument.Cells(1, 1 + 0).Bold = True &ExcelDocument.Cells(1, 1 + 0).Text = 'FORMATO 5.2: "LIBRO DIARIO DE FORMATO SIMPLIFICADO"' &ExcelDocument.Cells(2, &ExcelDocument.Cells(2, &ExcelDocument.Cells(2, &ExcelDocument.Cells(2, &ExcelDocument.Cells(3, &ExcelDocument.Cells(3, &ExcelDocument.Cells(3, &ExcelDocument.Cells(3, 1 1 2 2 1 1 2 2 + + + + + + + + 0).Bold 0).Text 0).Bold 0).Text 0).Bold 0).Text 0).Bold 0).Text = = = = = = = = True 'PERIODO:' True &nomMes True 'RUC:' True &EmpreRuc

&ExcelDocument.Cells(4, 1 + 0).Bold = True &ExcelDocument.Cells(4, 1 + 0).Text = 'RAZ.SOCIAL:' &ExcelDocument.Cells(4, 2 + 0).Bold = True &ExcelDocument.Cells(4, 2 + 0).Text = &EmpreDes /////CANTIDAD DE CUENTAS For each defined by AsientoId,AsientoMes,AsiDetGlosa For each AsientoNum where AsientoMes=&PeriMes &CuentaCuentas=&CuentaCuentas+1 // Write cell values endfor Endfor // Write titles &ExcelDocumentAjustado.AutoFit=1 &ExcelDocument.Cells(&CellRow, &FirstColumn + 0).Bold = True &ExcelDocument.Cells(&CellRow, &FirstColumn + 0).Text = 'CODIGO' &ExcelDocument.Cells(&CellRow, &FirstColumn + 1).Bold = True &ExcelDocument.Cells(&CellRow, &FirstColumn + 1).Text = 'FECHA' &ExcelDocument.Cells(&CellRow, &FirstColumn + 2).Bold = True &ExcelDocument.Cells(&CellRow, &FirstColumn + 2).Text = 'GLOSA' //6,3 //for &y=1 to &CuentaCuentas // For each defined by AsientoId,AsientoMes,AsiDetGlosa // For each AsientoNum // // where AsientoMes=&PeriMes // &ExcelDocument.Cells(6, 2 + (2+&y)).Bold = True // &ExcelDocument.Cells(6,2 + (2+&y)).Number =&y // endfor // endfor //endfor //For each defined by AsientoId,AsientoMes,AsiDetGlosa // For each AsientoNum // where AsientoMes=&PeriMes //for &y=1 to &CuentaCuentas // endfor //endfor

For each defined by AsientoId,AsientoMes,AsiDetGlosa,PlanCuentaNivel For each AsientoNum where AsientoMes=&PeriMes //and PlanCuentaNivel='1' // Write cell values &AsientoId=str(AsientoId) &SubDiarioId=SubDiarioId &AsientoNum=str(AsientoNum) &CellRow += 1 &ExcelDocument.Cells(&CellRow, &FirstColumn LTrim(&AsientoNum) &ExcelDocument.Cells(&CellRow, &FirstColumn &ExcelDocument.Cells(&CellRow, &FirstColumn if PlanCuentaNivel='3' &planExtrae=substr(PlanCuentaId,1,2) &ExcelDocument.Cells(6, &CellRow -3).Text = endif &ExcelDocument.Cells(7, &CellRow -3).Number

+ 0).Text = &AsientoId+ &SubDiarioId + + 1).Date = AsientoFec + 2).Text = AsiDetGlosa &planExtrae = AsiDetDebes

//&ExcelDocument.Cells(7,2 + (2+&y)).Number =AsiDetDebes endfor Endfor //CALCULANDO DEBE-HABER For each AsientoNum where AsientoMes=&PeriMes For each (AsientoMes, SubDiarioCodigo, AsientoNum) if &opcion=0 //cuando es soles &enDebe =AsiDetDebes &enHaber=AsiDetHabers else //cuando es dolares &enDebe=AsiDetDebed &enHaber=AsiDetHaberd endif //for &var = 1 to &CuentaCuentas// people &Matriz.Add(PlanCuentaId)//substr(PlanCuentaId,1,2)) for &i=1 to &CuentaCuentas for &i in &Matriz if PlanCuentaId=str(&i) &MatrizN.Add(PlanCuentaId) for &i=1 to &CuentaCuentas &ExcelDocument.Cells(10, 20 -3).Number = &i endfor endif endfor endfor &totaldebe = &totaldebe+&enDebe &totalhaber = &totalhaber+&enHaber //&ExcelDocument.Cells(8, &CellRow -3).Number = &totaldebe-&totalhaber Endfor Endfor //&Matriz(50)= 0 //For &var = 1 to 10 // &Matriz(&var) = AsiDetHaberd //Endfor &ExcelDocument.Save() Do 'CheckStatus' &ExcelDocument.Close() Sub 'CheckStatus' If (&ExcelDocument.ErrCode <> 0) &Filename = ""

//&ErrorMessage = &ExcelDocument.ErrDescription &ExcelDocument.Close() Return Endif Endsub

You might also like