翻譯|使用教程|編輯:王香|2019-01-15 11:03:08.000|閱讀 345 次
概述:此示例項目顯示如何將報表shapshot項目導(dǎo)出到硬盤驅(qū)動器上的文件。為此,您可以使用reportsnapshots命令組的export REST命令。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
此示例項目顯示如何將報表shapshot項目導(dǎo)出到硬盤驅(qū)動器上的文件。為此,您可以使用reportsnapshots命令組的export REST命令。作為參數(shù),您需要使用導(dǎo)出參數(shù)指定文件項名稱和導(dǎo)出集。這些參數(shù)可以作為請求發(fā)布數(shù)據(jù)傳遞。
var reportSnapshotKey = "897324aec5154c6fb102f47ff9267a42"; var url = "//localhost:40010/1/reportsnapshots/" + reportSnapshotKey + "/export"; var requestRun = WebRequest.Create(url); requestRun.Method = "PUT"; requestRun.ContentType = "application/x-www-form-urlencoded"; requestRun.Headers.Add("x-sti-SessionKey", sessionKey); requestRun.Headers.Add("x-sti-DestinationItemKey", filefolderKey); var postData = "{ 'FileItemName':'ExportReport.pdf', 'ExportSet':" + "{ 'Ident':'Pdf', 'PageRange':{ },'EmbeddedFonts':false,'DitheringType':'None','PdfACompliance':true} }"; byte[] bytes = Encoding.GetEncoding(1251).GetBytes(postData); Request(requestRun, postData); var s = GetResponseResult(requestRun);
您可以使用以下方法將請求發(fā)送到服務(wù)器并獲取請求的結(jié)果。
private void Request(WebRequest request, string postData) { var bytesCreateSnapshot = Encoding.GetEncoding(1251).GetBytes(postData); request.ContentLength = bytesCreateSnapshot.Length; using (Stream ws = request.GetRequestStream()) { ws.Write(bytesCreateSnapshot, 0, bytesCreateSnapshot.Length); ws.Flush(); } } private string GetResponseResult(WebRequest request) { var resp = request.GetResponse(); var respStream = resp.GetResponseStream(); if (respStream != null) { using (var stream1 = new StreamReader(respStream)) { var s = stream1.ReadToEnd(); return s; } } return null; }
下面的屏幕截圖中,您可以看到示例代碼的結(jié)果。
購買Stimulsoft正版授權(quán),請點擊“”喲!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn