wpf 中可以使用reportingservers ,水晶報表等東西,但是如果使用reportingservers 在頻繁的資料互動中是 比較浪費資源或者存在效率問題。所以還有沒有更好的辦法呢。答案肯定是有的。
wpf中基於模板的報表設計就可以完成以上內容,對於要修改的報表檔案是以檔案的方式存放在伺服器上,每次讀取報表檔案還是很方便的!
第二部:建立你要做的報表檔案:
點選單
營業點: @shopwork
台號: @tableno
---------------------------------------------
---------------------------------------------
卡號:@cardno
賬單號:@billno
會員號:@memono
人數:@memocount
姓名:@name
日期:@date
服務員: @operator
複製**
裡面的內容大家可以看下,wpf 中就要用table標籤,如果用grid 展示的話,在xp 會不相容!
以上就是報表檔案了
第三步:在wpf 窗體中呼叫;
頁面中加入documentviewer 控制項,用來展示 報表
reportdocument reportdocument = new reportdocument();
streamreader reader = new streamreader(new filestream(path + @"template\performance.template.xaml", filemode.open, fileaccess.read)); // 讀取報表的模板檔案
reportdocument.xamldata = getcontent(reader.readtoend()); // 這裡是替換模板檔案中的 靜態變數內容
reportdocument.xamlimagepath = path.combine(environment.currentdirectory, @"template\");//幾乎用不到
reader.close();
reportdata data = new reportdata();
var table = getroundscore();
data.datatables.add(table); //根據報表檔案中的data資料 賦值
xpsdocument xps = reportdocument.createxpsdocument(data);
documentviewer.document = xps.getfixeddocumentsequence(); // 展示報表
複製**
報表的預覽完成了,你可以呼叫預覽視窗中的 列印按鈕列印。也可以自己 新增列印事件!內容如下:
documentviewer.document = null;
printdialog pd = new printdialog();
dataset ds = createreportcondata(_billno);
if (ds.tables[0].rows.count > 0)
複製**
以上如果不預覽的話,直接可以new 這樣的窗體,呼叫上面的方法可以直接列印
word 模板 設計 報表 列印
word列印元件以元資料為基礎,使實現了從word模板設計 繫結資料 文件輸出的功能。主要功能如下 伺服器不需要安裝office,即可生成繫結資料後的word檔案 實現了word模板從設計到輸出 支援單錶輸出 多表的輸出 支援複雜格式 支援多行資料輸出 支援單選 核取方塊輸出 支援資料自定義格式的輸...
基於VB和EXCEL的報表設計及列印
with zsbexcel.activesheet.range a2 c9 borders linestyle xlborderlinestylecontinuous weight xlthin colorindex 1 end with with zsbexcel.activesheet.rang...
討論建立基於WSE的報表列印服務及其實現
引言 wse提供了乙個非常方便的功能,就是支援附件的傳輸,儘管我們可以採用別的方式來達到這個目的,比如直接的返回byte型的資料,但是對於大多數應用而言,直接返回乙個附件,如一張更為實在些,請大家不要誤會我文章的標題,以為建立乙個webservice就可以方便地實現了列印了,我們的軟體原理和最終列印...