我在android.so中创建了报表,我在JSON
的表中显示了itext-pdf
数据。我有Json
使用retrofit2和rxjava2进行解析。
在Json
格式中,一个是密钥"FirmName"
。 FirmName
键值与其对象相同
数据显示在一个表中,但是当FirmName
值更改时,其自身的对象数据将动态显示在另一表中。
当数据如何显示在另一个表中时,我没有FirmName
值更改吗?
JSON格式为:
{
"status": 1,
"0": [
{
"Cmp_Name": "ABC",
"Partyid": "18",
"ChallanNo": "-",
"PartyName": "PURCHASE GJ",
"FirmName": "PURCHASE GJ",
"ChallanDate": "-",
"ChallanAmount": "0.0",
"RecieveDate": "2019-03-15 00:00:00",
"RecieveAmount": "4000.0",
"DiscountAmount": "0.0",
"TDSAmount": "0.0",
"Bank": "AXIS BANK",
"ChequeNo": null,
"ChequeDate": null
},
{
"Cmp_Name": "ABC",
"Partyid": "17",
"ChallanNo": "20",
"PartyName": "PURCHASE GJ",
"FirmName": "PURCHASE GJ",
"ChallanDate": "3/11/2019",
"ChallanAmount": "1391.0",
"RecieveDate": "2019-03-15 00:00:00",
"RecieveAmount": "1391.0",
"DiscountAmount": "0.0",
"TDSAmount": "0.0",
"Bank": "AXIS BANK",
"ChequeNo": "321456",
"ChequeDate": "2019-03-15 00:00:00"
},
{
"Cmp_Name": "ABC",
"Partyid": "17",
"ChallanNo": "20",
"PartyName": "Dharama",
"FirmName": "Dharama",
"ChallanDate": "3/11/2019",
"ChallanAmount": "1391.0",
"RecieveDate": "2019-03-15 00:00:00",
"RecieveAmount": "1391.0",
"DiscountAmount": "0.0",
"TDSAmount": "0.0",
"Bank": "AXIS BANK",
"ChequeNo": "321456",
"ChequeDate": "2019-03-15 00:00:00"
},
{
"Cmp_Name": "ABC",
"Partyid": "17",
"ChallanNo": "20",
"PartyName": "Dharama",
"FirmName": "Dharama",
"ChallanDate": "3/11/2019",
"ChallanAmount": "1391.0",
"RecieveDate": "2019-03-15 00:00:00",
"RecieveAmount": "1391.0",
"DiscountAmount": "0.0",
"TDSAmount": "0.0",
"Bank": "AXIS BANK",
"ChequeNo": "321456",
"ChequeDate": "2019-03-15 00:00:00"
}
]
}
以上JSON
格式FirmName
中,两个值相同而两个值不同。
FirmName
相同的值是“购买GJ”,其自身的对象数据显示在一个表中,而佛法值数据则在另一表中。如何显示?
下面的代码是itext pdf
中一个表中显示的数据,但是我不知道要创建另一个表取决于键值的更改。
Json
表中的数据显示itxet pdf
。
所有JSON
数据在代码下均显示一个表,但是如何创建表取决于JSON
键“ PartyName
”的值更改表是否已创建?
我正在使用Retrofit2和rxjava2来解析JSON
数据。
我必须分离表中显示的数据。
“ PartyName
”是JSON
键。当“ PartyName
”更改其对象数据在另一表中的显示时,“ PartyName
”值与其在一个表中显示相同。
PartyName
值更改其创建的新表显示数据。
如何在itext pdf
中创建更多表格,请指导我?
还有其他适用于Android的报告工具吗?
在itext pdf
中创建一个表,但我想在JSON
上方使用数据键“ PartyName
”来更改另一个表中的显示数据。
下面的代码是另一个不在Json
数据代码之上的数据代码。
fun pdfViewer(purchaseOut: List, fDate : String, tDate : String, todayDate : String) {
val document = Document()
try {
val SDCardRoot = Environment.getExternalStorageDirectory()
val dir = File(SDCardRoot.getAbsolutePath() + dirPath)
if (!dir.exists()) {
dir.mkdirs()
}
val d = Date()
val s = DateFormat
.format("yyyyMMdd", d.getTime())
val ran = java.util.Random()
var n = 10000
n = ran.nextInt(n)
//var file = File(dir, ".pdf")
//val targetPdf = "/sdcard/pdffromlayout.pdf"
// val targetPdf = file
val pathName: String = "purchaseOut" + s + ".pdf"
val filePath: File
filePath = File(dir, pathName)
val docWriter = PdfWriter.getInstance(document, FileOutputStream(filePath))
document.open()
val cb = docWriter.getDirectContent()
initializeFonts()
createHeadings(cb, 260F, 780F, companyName )
createHeadings(cb, 190F, 765F, "Party Wise Purchase Pending Report(Summary)")
//createHeadings(cb, 265F, 750F, "GST IN : "+ salesGSt.get(1).GSTIN)
createHeadings(cb, 35F, 660F, "Date : "+todayDate)
createHeadings(cb, 327F, 660F, "From Date :" +fDate)
createHeadings(cb, 439F, 660F, "To Date :"+tDate)
/* var header = PdfPTable(1)
var cellHeader = PdfPCell(Phrase("CompanyName"))
header.setHorizontalAlignment(Element.ALIGN_CENTER)
// cellHeader.setName("Hi")
header.addCell(cellHeader)
header.setWidthPercentage(100F)*/
val columnWidths = floatArrayOf(0.75f, 5f, 2f, 2f, 2.5f, 2f, 2.5f)
//var cell : PdfPCell
var table = PdfPTable(columnWidths)
table.setTotalWidth(500f)
var cell = PdfPCell(Phrase("Sr.No"))
cell.setHorizontalAlignment(Element.ALIGN_RIGHT)
table.addCell(cell)
cell = PdfPCell(Phrase("Party Name"))
cell.setHorizontalAlignment(Element.ALIGN_LEFT)
table.addCell(cell)
cell = PdfPCell(Phrase("Opening Balance"))
cell.setHorizontalAlignment(Element.ALIGN_LEFT)
table.addCell(cell)
cell = PdfPCell(Phrase("Bill Amount"))
cell.setHorizontalAlignment(Element.ALIGN_RIGHT)
table.addCell(cell)
cell = PdfPCell(Phrase("Rcv Amount"))
cell.setHorizontalAlignment(Element.ALIGN_RIGHT)
table.addCell(cell)
cell = PdfPCell(Phrase("Other Amount"))
cell.setHorizontalAlignment(Element.ALIGN_RIGHT)
table.addCell(cell)
cell = PdfPCell(Phrase("Closing Balance"))
cell.setHorizontalAlignment(Element.ALIGN_RIGHT)
table.addCell(cell)
table.setHeaderRows(1)
val df = DecimalFormat("0.00")
for (j in 0 until purchaseOut.size) {
val price = java.lang.Double.valueOf(df.format(Math.random() * 10))
// val extPrice = price * (i + 1)
/*val inputFormatter1 = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
val date1 = inputFormatter1.parse(salesGSt.get(j).ChallanDate)
val outputFormatter1 = SimpleDateFormat("dd-MMM-yyyy")
var bill_date = outputFormatter1.format(date1)*/
if (purchaseOut.get(j).FirmName != null) {
partyName = purchaseOut.get(j).FirmName!!
} else {
partyName = ""
}
if (purchaseOut.get(j).Balance != null) {
openingBalance = purchaseOut.get(j).Balance!!
} else {
openingBalance = ""
}
if (purchaseOut.get(j).CR != null) {
billAmount = purchaseOut.get(j).CR!!
} else {
billAmount = ""
}
if (purchaseOut.get(j).DB != null) {
rcvAmt = purchaseOut.get(j).DB!!
} else {
rcvAmt = ""
}
if (purchaseOut.get(j).OtherAmt != null) {
otherAmt = purchaseOut.get(j).OtherAmt!!
} else {
otherAmt = ""
}
if (purchaseOut.get(j).ClBalance != null) {
cLBalance = purchaseOut.get(j).ClBalance!!
} else {
cLBalance = ""
}
table.addCell((j + 1).toString())
table.addCell(partyName)
table.addCell(openingBalance)
table.addCell(billAmount)
table.addCell(rcvAmt)
table.addCell(otherAmt)
table.addCell(cLBalance)
//table.addCell(df.format(extPrice))
}
table.writeSelectedRows(0, -1, document.leftMargin(), 650F, docWriter.getDirectContent())
document.close()
openGeneratedPDF(pathName)
} catch (e: Exception) {
e.printStackTrace()
}
}
android可以支持报告工具或库吗?