简体   繁体   中英

Why does all data in my Excel RDLC data start at row 2?

The column headers for an Excel report generated using RDLC always seem to start at ROW TWO. However, I need the data to start at ROW ONE, but I cannot seem to figure it out.

MY QUESTION:
Is there a way to force the data-rows to start at ROW ONE?

THE RENDERED REPORT LOOKS LIKE:
As you can see, the data starts at Row 2...

在此处输入图片说明

MY REPORT DESIGNER LOOKS LIKE:
As you can see, the column header is atop the designer and the fields are listed below. Of course, the Title and Image are above this area and have no bearing on the data results view area. 在此处输入图片说明

MY INITIAL CODE LOOKS LIKE:
I can post more code. However, this is the only piece specific to the "Local Drivers Report" export.

public ActionResult Export(string id)
{
    var format = !string.IsNullOrEmpty(id) ? id : SsrsExportFormat.Image.ToString();
    var localDrivers = from x in LocalDriverInfo
                       select new
                       {
                           Title = x.Title.TranslatedName,
                           x.Driver.ConfirmedWith,
                           x.Driver.CurrentState,
                           x.Driver.Description,
                           x.Driver.DesiredState,
                           x.Driver.LocalDriverId,
                           x.Driver.LocalDriverTitleId
                       };

    var lsDs = new List<ReportDataSource> { ReportGenerator.GetDataSource(localDrivers, "LocalDrivers"), ReportGenerator.GetDataSource(GetReportResource(), "Resource") };
    var lsDsResult = lsDs.ToList();
    var message = string.Format("Controller: LocalDrivers, Action: Export(id), "
                              + "Parameters: [id: {0}, lsDs count: {1}, format: {2}]"
                              , id, lsDsResult.Count, format);

    TraceHandler.AddEntry(message, TraceHandler.TraceTypes.Information);

    //The DeviceInfo settings should be changed based on the reportType
    //http://msdn2.microsoft.com/en-us/library/ms155397.aspx            
    return GetRenderedReport(format, "~/Reports/LocalDrivers/LocalDrivers.rdlc", lsDs, "Local Drivers", ReportGenerator.GetDeviceInfoLetterLandscape(format), null);
}

Make sure that there is absolutely no white space on the top and the left of your table. Any white space will create extra row.

As it turned out, the DEVICE INFO settings were the answer to this particular problem.

THE DEVICE INFO XML SHOULD LOOK LIKE:
DeviceInfo is passed into the ServerReport.Render method when creating the 'local report'.

<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>

THE CODE LOOKS LIKE:
Notice the last appended line...

var deviceInfo = new StringBuilder();
deviceInfo.Append("<DeviceInfo>");
deviceInfo.AppendFormat("<OutputFormat>{0}</OutputFormat>", format);
deviceInfo.AppendFormat("<PageWidth>{0}</PageWidth>", pageWidth);
deviceInfo.AppendFormat("<PageHeight>{0}</PageHeight>", pageHeight);
deviceInfo.AppendFormat("<MarginTop>{0}</MarginTop>", marginTop);
deviceInfo.AppendFormat("<MarginLeft>{0}</MarginLeft>", marginLeft);
deviceInfo.AppendFormat("<MarginRight>{0}</MarginRight>", marginRight);
deviceInfo.AppendFormat("<MarginBottom>{0}</MarginBottom>", marginBottom);
deviceInfo.AppendFormat("<SimplePageHeaders>{0}</SimplePageHeaders>", isSimplePageHeaders);
deviceInfo.Append("</DeviceInfo>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM