私は現在、選択された各アイテムを読み込み、アイテムのバーコードを含むセルを作成する(エクスポートするセルは、ユーザーが入力した数に依存します)、DataGridViewからループしていますが、私はpdfTable.Columns(5)を持っているので、1つのバーコードラベル(1 pdfCell)はエクスポートされず、「pdfTableは空です」と表示されます。これは、私のテーブルのカラム数が5であることを意味します。 5で割り切れないセル量をエクスポートしないでください。pdfCellの数と等しくないか、または割り切れるpdfTableをエクスポートするにはどうすればいいですか?
例1:アイテム - バナナ(10バーコード印刷する) - エクスポート
例2:アイテム - アップル(1つのバーコード印刷する) - 1(1)がカバーしていないため、エクスポートされないが(PDFTableは空です) 5(5)の列カウントを持つpdfTableの単一の行。ここで
Public Function print_itembarcodes(lbl169 As Label)
Dim pdfTable As New PdfPTable(5)
pdfTable.DefaultCell.Padding = 3
pdfTable.WidthPercentage = 100
pdfTable.HorizontalAlignment = Element.ALIGN_CENTER
pdfTable.DefaultCell.Border = Rectangle.NO_BORDER
For i As Integer = 0 To Admin_Menu.BarcodePrintListGrid.Rows.Count - 1
Admin_Menu.Label169.Text = Admin_Menu.BarcodePrintListGrid.Rows(i).Cells(1).Value 'Item Barcode'
Barcode.process_printbarcode(Admin_Menu.Label169) 'Make barcode image function'
save_printbarcode() 'Save barcode to desktop function'
For j As Integer = 0 To Admin_Menu.BarcodePrintListGrid.Rows(i).Cells(5).Value 'Quantity of barcodes to be printed per item'
pdfTable.AddCell(create_barcodecell) 'Add cell with barcode function'
Next
Next
Try
'Exporting to PDF
Dim folderPath As String = "C:\Temp\"
If Not Directory.Exists(folderPath) Then
Directory.CreateDirectory(folderPath)
End If
Using stream As New FileStream(folderPath & "temp2.pdf", FileMode.Create)
Dim pdfdoc As New Document(PageSize.A4, 15.0F, 15.0F, 10.0F, 20.0F)
PdfWriter.GetInstance(pdfdoc, stream)
pdfdoc.Open()
pdfdoc.Add(pdfTable) 'Table Declaration'
pdfdoc.Close()
stream.Close()
System.Diagnostics.Process.Start("C:\\Temp\\temp2.pdf")
End Using
Catch ex As MySqlException
MsgBox(ex.Message)
Finally
MysqlConn.Dispose()
End Try
Return True
End Function
は、バーコードを用いて細胞を作成するための私のコードです:
Public Function create_barcodecell()
Dim SaveFileDialog1 = "D:\School\Capstone\Sta. Lucia East Bowling and Billiard Hall Management System\Item Barcodes\"
Dim Barcode2 As Image = Image.GetInstance(SaveFileDialog1 + Admin_Menu.Label169.Text + ".jpg") 'Barcode Image'
Barcode2.ScaleAbsolute(80.0F, 25.0F)
img.ScalePercent(15.0F) 'Company Logo Image'
img.Alignment = iTextSharp.text.Image.ALIGN_RIGHT
Dim titleFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)
Dim paragraph As New Paragraph()
paragraph.Add(New Chunk(img, 0, 0))
paragraph.Add(New Chunk(" Item Tag", titleFont))
Dim pdfCell As New PdfPCell
pdfCell.UseVariableBorders = True
pdfCell.BackgroundColor = BaseColor.GRAY
pdfCell.BorderColorLeft = BaseColor.GREEN
pdfCell.BorderColorRight = BaseColor.GREEN
pdfCell.BorderColorTop = BaseColor.GREEN
pdfCell.BorderColorBottom = BaseColor.GREEN
pdfCell.AddElement(paragraph)
pdfCell.AddElement(Barcode2)
pdfCell.AddElement(New Paragraph(" " + Admin_Menu.Label169.Text, titleFont))
Return pdfCell
End Function
a)「Option Strict」をオンにします。b)あなたの投稿に明確な問題文がないため、おそらく3回近くの投票があります。 * PdfTable/Documentは空です。* oh-by-the-way節のようなものとしてタックされています。c)私たちはあなたが投稿して私たちに伝えるあなたのアプリについてもう知りません。したがって、「BarcodePrintListGrid.Rows(i).cells(5).value」の記述は、col5が何を表しているかわからないため、何も教えてくれません。 d)Admin_menuとは何かが不明な点がいくつかあります。 – Plutonix
@Plutonix列5は、ユーザーがその項目に対して印刷したいバーコードラベルの数量の値です。例えば、Item-Banana(5 Barcode to Print)5は、印刷するバーコードであるColumn 5の値です。Admin_Menuは、私の投稿に記載されているすべてのコントロールが入っているフォームです。 –
@Plutonix私は私のことを推測していますエラーは 'For j as integer = 0 to Admin_Menu.BarcodePrintListGrid.Rows(i).Cells(5).Value'ループにあります。なぜなら、その値を '3'に変更したときに4つのバーコードラベルが印刷されたからです他の数字は再び空のテーブルに戻ってきました... –