2015-04-01 32 views
-2

我已經做了2列報表就是這個樣子空:的第一條記錄的地方是在RDLC報告

Name1----------------------------Name3 
Address1-------------------------Address3 

Name2----------------------------Name4 
Address2-------------------------Address4 

但它突然開始給這樣的報道:

 ----------------------------Name3 
     -------------------------Address3 

Name1----------------------------Name4 
Address1-------------------------Address4 

Name2 
Address2 

這是我的代碼:

public ActionResult Report() 
     { 
      LocalReport lr = new LocalReport(); 
      string path = Path.Combine(Server.MapPath("~/Report"), "Person.rdlc"); 
      if (System.IO.File.Exists(path)) 
      { 
       lr.ReportPath = path; 
      } 
      else 
      { 
       return View("Index"); 
      } 
      List<Person> cm = new List<Person>(); 

      var viewModel = new PersonIndexData(); 

      viewModel.People = db.Person 
      .Include(k => k.Groups) 
      .OrderBy(k => k.Name); 

      cm = viewModel.People.ToList(); 



      ReportDataSource rd = new ReportDataSource("DataSet1", cm); 
      lr.DataSources.Add(rd); 
      string reportType = "pdf"; 
      string mimeType = string.Empty; 
      string encoding = string.Empty; 
      string fileNameExtension = string.Empty; 



      string deviceInfo = 

      "<DeviceInfo>" + 
      " <OutputFormat>pdf</OutputFormat>" + 
      " <PageWidth>8.5in</PageWidth>" + 
      " <PageHeight>12in</PageHeight>" + 
      " <MarginTop>0.5in</MarginTop>" + 
      " <MarginLeft>0.5in</MarginLeft>" + 
      " <MarginRight>1in</MarginRight>" + 
      " <MarginBottom>0.2in</MarginBottom>" + 
      "</DeviceInfo>"; 

      Warning[] warnings; 
      string[] streams; 
      byte[] renderedBytes; 

      renderedBytes = lr.Render(
       "pdf", 
       deviceInfo, 
       out mimeType, 
       out encoding, 
       out fileNameExtension, 
       out streams, 
       out warnings); 


      return File(renderedBytes, mimeType); 
     } 

即第一條記錄的位置是空的。你爲什麼認爲它發生了,我怎麼能擺脫它?我改變了列間距和邊距,但沒有奏效。謝謝。

+1

顯示產生這個的代碼。你明顯在某個地方有偏移 – 2015-04-01 07:10:27

+0

@ThomasAndreèLian,補充說,謝謝。 – jason 2015-04-01 07:12:39

回答

3

您無法從表中獲取第一列值。這就是它無法顯示第一列值的原因。

+0

但是第一個值顯示爲第二個數據 – jason 2015-04-01 07:20:56

+3

如果您有更多的信息構建在您的答案上,請將其作爲編輯發佈到您當前的答案,而不是作爲一個全新的答案。目前,事情看起來很混亂,你的兩個「答案」只不過是評論而已。 – 2015-04-01 12:57:24