У меня есть веб-форма с выпадающим списком и текстовым полем и тремя кнопками. 1) сгенерировать отчет 2) распечатать 3) Экспорт в PDFкак передать другой отчет .rdlc в reportviewer
У меня есть printonebartest.rdlc как отчет по умолчанию, связанный с reportviewer1, который предназначен для просмотра пользователем информации, однако, когда я печатаю тот же отчет, html испортил , поэтому я создал другой отчет printonebartest1.rdlc, который масштабируется для правильной печати информации. Мой вопрос заключается в том, как я могу передать printonebartest1.rdlc в reportviewer1 при нажатии кнопки печати и экспорта в pdf.
Это код, у меня есть для кнопки печати
protected void Print_Click(object sender, ImageClickEventArgs e)
{
IolaNetWeightWeb.BarTableAdapters.Product_Weight_Data_Sheet_QueryTableAdapter ds = new IolaNetWeightWeb.BarTableAdapters.Product_Weight_Data_Sheet_QueryTableAdapter();
ReportDataSource rds = new ReportDataSource("Bar_Product_Weight_Data_Sheet_Query", ds.GetData(DropDownList1.Text, DropDownList3.Text));
// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
// Setup the report viewer object and get the array of bytes
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "printonebartest1.rdlc";
viewer.LocalReport.DataSources.Add(rds); // Add datasource here
byte[] bytes = ReportViewer1.LocalReport.Render("Pdf", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "inline; filename=PrintOneBar.pdf");
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download
}
даже если я передаю printonebartest1.rdlc он все еще использует printonebartest.rdlc я делаю что-то здесь не так, у меня пересвязать источник данных или что-то? пожалуйста, помогите любой помощи.
Вопрос был помечен iText, но я не вижу никакого iText-кода. Вы уверены, что вам нужен этот тег? –
@AmedeeVanGasse ваше право жаль, что я думал, что печать и экспорт в pdf использовали itext. – CodeMan