Веб -API и просмотрщик отчетовC#

Место общения программистов C#
Ответить
Anonymous
 Веб -API и просмотрщик отчетов

Сообщение Anonymous »

У меня есть требование для создания в веб -API службу, которая вернет PDF файла локального просмотра отчетов. Кто -нибудь когда -нибудь пробовал или имел успех в попытке сделать что -то подобное? Все мои попытки попытаться поднять байт [] в поток, а затем вывод в качестве Httpresponse закончились пустыми файлами. < /P>

public FileResult File() {
// Create a new dataset
StudentDataSet ds = new StudentDataSet();

// Create and fill the Student data table
// using the Student table adapter

StudentDataSetTableAdapters.StudentTableAdapter dta =
new StudentDataSetTableAdapters.StudentTableAdapter();
dta.Fill(ds.Student);

// Create a new report datasource with
// Name = the dataset name in the report,
// Value = the populated data table.

ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";
rds.Value = ds.Student;

ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer();
rv.ProcessingMode = ProcessingMode.Local;
rv.LocalReport.ReportPath = Server.MapPath("~/Reports/StudentReport.rdlc");

// Add the new report datasource to the report.
rv.LocalReport.DataSources.Add(rds);

rv.LocalReport.Refresh();

byte[] streamBytes = null;
string mimeType = "";
string encoding = "";
string filenameExtension = "";
string[] streamids = null;
Warning[] warnings = null;

streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

return File(streamBytes, mimeType, "StudentReport.pdf");
}


Подробнее здесь: https://stackoverflow.com/questions/265 ... ort-viewer
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»