2016-06-23 1 views
0

주기가있는 동안 테이블을 생성했지만 마지막 행 iTextSharp를 잘라 버렸습니다. 아무나 아이디어를 수정하여 .... 아래 코드를 참조하십시오.iTextSharp - 테이블의 마지막 행을 자르십시오.

mesure_tale.AddCell(New PdfPCell(New Phrase("č.m.", spec_font))) 
     mesure_tale.AddCell(New PdfPCell(New Phrase("Hodnota (mm)", spec_font))) 
     mesure_tale.AddCell(New PdfPCell(New Phrase("č.m.", spec_font))) 
     mesure_tale.AddCell(New PdfPCell(New Phrase("Hodnota (mm)", spec_font))) 
     mesure_tale.AddCell(New PdfPCell(New Phrase("č.m.", spec_font))) 
     mesure_tale.AddCell(New PdfPCell(New Phrase("Hodnota (mm)", spec_font))) 
     mesure_tale.AddCell(New PdfPCell(New Phrase("č.m.", spec_font))) 
     mesure_tale.AddCell(New PdfPCell(New Phrase("Hodnota (mm)", spec_font))) 

     Dim mesure_array As Double() = dgv_do_array(cislo_merania) 
     Dim average_value As Double = create_average(cislo_merania) 

     Dim k As Integer = 0 
     While k < cislo_merania 
      mesure_tale.AddCell(New PdfPCell(New Phrase(k + 1, spec_font))) 
      Dim mesure_cell As New PdfPCell(New Phrase(mesure_array(k).ToString, spec_font)) 

      If mesure_array(k) > (average_value + (average_value * percentualna_odchylka)) Then 
       mesure_cell.BackgroundColor = New BaseColor(255, 120, 120) 'Red 
       mesure_tale.AddCell(mesure_cell) 
      ElseIf mesure_array(k) < (average_value - (average_value * percentualna_odchylka)) Then 
       mesure_cell.BackgroundColor = New BaseColor(120, 170, 255) 'Blue 
       mesure_tale.AddCell(mesure_cell) 
      Else 
       mesure_cell.BackgroundColor = New BaseColor(175, 255, 120) ' Green 
       mesure_tale.AddCell(mesure_cell) 
      End If 
      k += 1 
     End While 

     pdfDoc.Add(mesure_tale) 
+0

당신이 버려야되는 것 확실합니까? 디버거에서'mesure_tale'을보고 모든 행이 포함되어 있는지 확인 했습니까? 필자는 Thomas Inzina가 제안한대로 마지막 while 행이 while 루프에 의해 추가되지 않는다고 생각합니다. – Phil

+0

난 그냥 디버그 출력을 찾고, 그 사실, 마지막 행이 누락되었습니다 ... 그것은 사이클이 나쁜 건설 ... 오클라호마, 내 사이클을 다시 디버그하고 우리는 볼 것이다 .... THX. – Oliwer11

답변

2

dgv_do_array(cislo_merania)은 배열의 실제 길이가 아니라 배열의 가장 높은 경계를 반환한다고 생각합니다.

변경

동안 K < cislo_merania

으로

동안 K < = cislo_merania

+0

이 픽스를 시도했지만 오순절 오류를 종료 ... 그래서 iTextSharp 라이브러리의 일부 stting이야 ... – Oliwer11

+0

iTextSharp 경우에만 전체 행을 보여줍니다. 열 개수에 오류가 있으면 마지막 행이 완료되지 않고 그 이유 때문에 삭제됩니다. 'CompleteRow()'메서드를 사용하면이를 피할 수 있습니다. 그래도 작동하지 않으면 사용중인 iText의 버전을 확인하십시오. 문서화 된 바와 같이, iText 5 이전의 버전은 설명 할 수없는 이유로 1 조 회에 한 번 행을 삭제했습니다 (수정하기 어려운 가장자리 경우). 이 문제는 오래 전에 수정되었으므로 최신 버전의 iTextSharp를 사용하고 있는지 확인하십시오. –

+0

마지막으로 사이클이 잘 구성되었습니다. ** CompleteRow ** 기능은 내가 찾는 것입니다. 고마워 – Oliwer11

관련 문제