Я получаю байтовый массив от отчета SSRS. Затем я хочу сохранить его в Excel на сервере для дальнейшей обработки.
Я могу экспортировать его в браузере клиента, но при попытке сохранить файл на сервере, который он сохраняет. Но дает ошибку во время открытия «Excel не может открыть файл, потому что формат файла или расширение файла недопустимо».Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer();
//Web Address of your report server (ex: http://rserver/reportserver)
rview.ServerReport.ReportServerUrl = new Uri("http://rserver/reportserver");
rview.ServerReport.ReportPath = "/Report Project2/Comment";
string mimeType, encoding, extension, deviceInfo;
string[] streamids;
Microsoft.Reporting.WebForms.Warning[] warnings;
string format = "Excel"; //Desired format goes here (PDF, Excel, or Image)
deviceInfo = "" + "True" + "";
byte[] bytes = rview.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
try
{
System.IO.FileStream _FileStream = new System.IO.FileStream(Server.MapPath("output.xlsx"), System.IO.FileMode.Create, System.IO.FileAccess.Write);
_FileStream.Write(bytes, 0, bytes.Length);
//_FileStream.Close();
}
catch (Exception _Exception)
{
Console.WriteLine("Exception caught in process: {0}", _Exception.ToString());
}
< /code>
Не знает, как использовать формат Infor, Deviceinfo и т. Д., Который я использую с объектом Spose для сохранения Excel в браузере клиента.Response.Clear();
if (format == "PDF")
{
Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition", "filename=output.pdf");
}
else if (format == "Excel")
{
Response.ContentType = "application/excel";
Response.AddHeader("Content-disposition", "filename=output.xls");
}
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.Flush();
Response.Close();
Подробнее здесь: https://stackoverflow.com/questions/193 ... excel-file
Сохраните байтовый массив для Excel File ⇐ C#
Место общения программистов C#
1758790910
Anonymous
Я получаю байтовый массив от отчета SSRS. Затем я хочу сохранить его в Excel на сервере для дальнейшей обработки.
Я могу экспортировать его в браузере клиента, но при попытке сохранить файл на сервере, который он сохраняет. Но дает ошибку во время открытия «Excel не может открыть файл, потому что формат файла или расширение файла недопустимо».Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer();
//Web Address of your report server (ex: http://rserver/reportserver)
rview.ServerReport.ReportServerUrl = new Uri("http://rserver/reportserver");
rview.ServerReport.ReportPath = "/Report Project2/Comment";
string mimeType, encoding, extension, deviceInfo;
string[] streamids;
Microsoft.Reporting.WebForms.Warning[] warnings;
string format = "Excel"; //Desired format goes here (PDF, Excel, or Image)
deviceInfo = "" + "True" + "";
byte[] bytes = rview.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
try
{
System.IO.FileStream _FileStream = new System.IO.FileStream(Server.MapPath("output.xlsx"), System.IO.FileMode.Create, System.IO.FileAccess.Write);
_FileStream.Write(bytes, 0, bytes.Length);
//_FileStream.Close();
}
catch (Exception _Exception)
{
Console.WriteLine("Exception caught in process: {0}", _Exception.ToString());
}
< /code>
Не знает, как использовать формат Infor, Deviceinfo и т. Д., Который я использую с объектом Spose для сохранения Excel в браузере клиента.Response.Clear();
if (format == "PDF")
{
Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition", "filename=output.pdf");
}
else if (format == "Excel")
{
Response.ContentType = "application/excel";
Response.AddHeader("Content-disposition", "filename=output.xls");
}
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.Flush();
Response.Close();
Подробнее здесь: [url]https://stackoverflow.com/questions/19314759/save-a-byte-array-to-excel-file[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия