Пример #1
0
        // 配置打印选项 纯文本文件
        private void button_print_optionText_Click(object sender, EventArgs e)
        {
            // 配置标题和风格
            string strNamePath = "accountbook_printoption_text";

            PrintOption option = new AccountBookPrintOption(this.MainForm.DataDir,
                this.comboBox_load_type.Text);
            option.LoadData(this.MainForm.AppInfo,
                strNamePath);

            PrintOptionDlg dlg = new PrintOptionDlg();
            MainForm.SetControlFont(dlg, this.Font, false);

            dlg.MainForm = this.MainForm;
            dlg.Text = this.comboBox_load_type.Text + " 纯文本 输出配置";
            dlg.DataDir = this.MainForm.DataDir;    // 允许新增模板页
            dlg.PrintOption = option;
            dlg.ColumnItems = new string[] {
                "no -- 序号",
                "barcode -- 册条码号",
                "summary -- 摘要",

                // 2009/7/24 
                "isbnIssn -- ISBN/ISSN",
                "publishTime -- 出版时间",
                "volume -- 卷期",
                "orderClass -- 订购类别",
                "catalogNo -- 书目号",
                "orderTime -- 订购时间",
                "orderID -- 订单号",
                "seller -- 渠道",
                "source -- 经费来源",
                "orderPrice -- 订购价",
                "acceptPrice -- 验收价",

                "accessNo -- 索取号",
                "state -- 状态",
                "location -- 馆藏地点",
                "price -- 册价格",
                "bookType -- 册类型",
                "registerNo -- 登录号",
                "comment -- 注释",
                "mergeComment -- 合并注释",
                "batchNo -- 批次号",
                /*
                "borrower -- 借阅者",
                "borrowDate -- 借阅日期",
                "borrowPeriod -- 借阅期限",
                 * */
                "recpath -- 册记录路径",
                "biblioRecpath -- 种记录路径",
                "biblioPrice -- 种价格",
                "refID -- 参考ID"
            };


            this.MainForm.AppInfo.LinkFormState(dlg, "accountbook_printoption_text_formstate");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
                return;

            option.SaveData(this.MainForm.AppInfo,
                strNamePath);
        }
Пример #2
0
        // 输出到文本文件
        int OutputToTextFile(
            List<ListViewItem> items,
            StreamWriter sw,
            ref XLWorkbook doc,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            Hashtable macro_table = new Hashtable();

            string strNamePath = "accountbook_printoption_text";

            // 获得打印参数
            PrintOption option = new AccountBookPrintOption(this.MainForm.DataDir,
                this.comboBox_load_type.Text);
            option.LoadData(this.MainForm.AppInfo,
                strNamePath);

            // 检查当前排序状态和包含种价格列之间是否存在矛盾
            if (bHasBiblioPriceColumn(option) == true)
            {

                if (this.SortColumns_in.Count != 0
                    && this.SortColumns_in[0].No == COLUMN_BIBLIORECPATH)
                {
                }
                else
                {
                    MessageBox.Show(this, "由于当前打印用到了 “种价格”列,为保证打印结果的准确,程序自动按 ‘种记录路径’ 列对全部列表事项进行一次自动排序。\r\n\r\n为避免这里的自动排序,可在打印前用鼠标左键点栏标题进行符合自己意愿的排序,只要最后一次点的是‘种记录路径’栏标题即可。");
                    ForceSortColumnsIn(COLUMN_BIBLIORECPATH);
                }
            }

            // 2009/7/24 changed
            if (this.SourceStyle == "batchno")
            {
                macro_table["%batchno%"] = HttpUtility.HtmlEncode(this.BatchNo); // 批次号
                macro_table["%location%"] = HttpUtility.HtmlEncode(this.LocationString); // 馆藏地点 用HtmlEncode()的原因是要防止里面出现的“<不指定>”字样
            }
            else
            {
                macro_table["%batchno%"] = "";
                macro_table["%location%"] = "";
            }

            // macro_table["%pagecount%"] = nPageCount.ToString();
            // macro_table["%linesperpage%"] = option.LinesPerPage.ToString();
            macro_table["%date%"] = DateTime.Now.ToLongDateString();

            // 2009/7/24 changed
            if (this.SourceStyle == "barcodefile")
            {
                macro_table["%barcodefilepath%"] = this.BarcodeFilePath;
                macro_table["%barcodefilename%"] = Path.GetFileName(this.BarcodeFilePath);
            }
            else
            {
                macro_table["%barcodefilepath%"] = "";
                macro_table["%barcodefilename%"] = "";
            }

            // 2009/7/30 
            if (this.SourceStyle == "recpathfile")
            {
                macro_table["%recpathfilepath%"] = this.RecPathFilePath;
                macro_table["%recpathfilename%"] = Path.GetFileName(this.RecPathFilePath);
            }
            else
            {
                Debug.Assert(this.SourceStyle == "batchno" || this.SourceStyle == "barcodefile", "");

                macro_table["%recpathfilepath%"] = "";
                macro_table["%recpathfilename%"] = "";
            }

            macro_table["%sourcedescription%"] = this.SourceDescription;

            IXLWorksheet sheet = null;

            // 输出统计信息页
            if (this.TextOutputStatisPart == true)
            {
                if (doc != null)
                {
                    sheet = doc.Worksheets.Add("统计页");
                    sheet.Style.Font.FontName = this.Font.Name;
                }

                int nItemCount = items.Count;
                int nBiblioCount = GetBiblioCount(items);
                string strTotalPrice = GetTotalPrice(items);

                macro_table["%itemcount%"] = nItemCount.ToString();
                macro_table["%bibliocount%"] = nBiblioCount.ToString();
                macro_table["%totalprice%"] = strTotalPrice;

                macro_table["%pageno%"] = "1";

                // 2008/11/23 
                macro_table["%datadir%"] = this.MainForm.DataDir;   // 便于引用datadir下templates目录内的某些文件
                ////macro_table["%libraryserverdir%"] = this.MainForm.LibraryServerDir;  // 便于引用服务器端的CSS文件

                string strTemplateFilePath = option.GetTemplatePageFilePath("统计页");
                if (String.IsNullOrEmpty(strTemplateFilePath) == false)
                {
                    /*
                     * TODO:修改为纯文本方式
<html>
<head>
	<LINK href='%libraryserverdir%/accountbook.css' type='text/css' rel='stylesheet'>
</head>
<body>
	<div class='pageheader'>%date% 财产帐簿 -- %sourcedescription% -- (共 %pagecount% 页)</div>
	<div class='tabletitle'>%date% 财产帐簿 -- %sourcedescription%</div>
	<div class='itemcount'>册数: %itemcount%</div>
	<div class='bibliocount'>种数: %bibliocount%</div>
	<div class='totalprice'>总价: %totalprice%</div>
	<div class='sepline'><hr/></div>
	<div class='batchno'>批次号: %batchno%</div>
	<div class='location'>馆藏地点: %location%</div>
	<div class='location'>条码号文件: %barcodefilepath%</div>
	<div class='location'>记录路径文件: %recpathfilepath%</div>
	<div class='pagefooter'>%pageno%/%pagecount%</div>
</body>
</html>
                     * * */

                    // 根据模板打印
                    string strContent = "";
                    // 能自动识别文件内容的编码方式的读入文本文件内容模块
                    // return:
                    //      -1  出错
                    //      0   文件不存在
                    //      1   文件存在
                    nRet = Global.ReadTextFileContent(strTemplateFilePath,
                        out strContent,
                        out strError);
                    if (nRet == -1)
                        return -1;

                    string strResult = StringUtil.MacroString(macro_table,
                        strContent);

                    if (sw != null)
                        sw.WriteLine(strResult);

                    // TODO: string --> excel page
                }
                else
                {
                    // 缺省的固定内容打印

                    // 内容行
                    if (sw != null)
                    {
                        sw.WriteLine("册数\t" + nItemCount.ToString());
                        sw.WriteLine("种数\t" + nBiblioCount.ToString());
                        sw.WriteLine("总价\t" + strTotalPrice);

                        sw.WriteLine("----------");


                        if (this.SourceStyle == "batchno")
                        {
                            // 2008/11/22 
                            if (String.IsNullOrEmpty(this.BatchNo) == false)
                            {
                                sw.WriteLine("批次号\t" + this.BatchNo);
                            }
                            if (String.IsNullOrEmpty(this.LocationString) == false
                                && this.LocationString != "<不指定>")
                            {
                                sw.WriteLine("馆藏地点\t" + this.LocationString);
                            }
                        }

                        if (this.SourceStyle == "barcodefile")
                        {
                            if (String.IsNullOrEmpty(this.BarcodeFilePath) == false)
                            {
                                sw.WriteLine("条码号文件\t" + this.BarcodeFilePath);
                            }
                        }

                        // 2009/7/30 
                        if (this.SourceStyle == "recpathfile")
                        {
                            if (String.IsNullOrEmpty(this.RecPathFilePath) == false)
                            {
                                sw.WriteLine("记录路径文件\t" + this.RecPathFilePath);
                            }
                        }


                        sw.WriteLine("----------");
                        sw.WriteLine("");
                    }

                    if (doc != null)
                    {
#if NO
                        int nLineIndex = 2;

                        doc.WriteExcelLine(
    nLineIndex++,
    "册数",
    nItemCount.ToString());

                        doc.WriteExcelLine(
    nLineIndex++,
    "种数",
    nBiblioCount.ToString());

                        doc.WriteExcelLine(
nLineIndex++,
"总价",
strTotalPrice);
#endif
                        
                        int nLineIndex = 2;

                        WriteValuePair(sheet,
    nLineIndex++,
    "册数",
    nItemCount.ToString());

                        WriteValuePair(sheet,
    nLineIndex++,
    "种数",
    nBiblioCount.ToString());

                        WriteValuePair(sheet,
nLineIndex++,
"总价",
strTotalPrice);           
                    }

                }

            }

            string strMarcFilterFilePath = option.GetTemplatePageFilePath("MARC过滤器");
            if (String.IsNullOrEmpty(strMarcFilterFilePath) == false)
            {
                nRet = PrepareMarcFilter(strMarcFilterFilePath, out strError);
                if (nRet == -1)
                    return -1;
            }

            if (doc != null)
            {
                sheet = doc.Worksheets.Add("财产帐");
                sheet.Style.Font.FontName = this.Font.Name;

#if NO
                Columns columns = new Columns();
                DocumentFormat.OpenXml.Spreadsheet.Column column = new DocumentFormat.OpenXml.Spreadsheet.Column();
                column.Min = 4;
                column.Max = 4;
                column.Width = 40;
                column.CustomWidth = true;
                columns.Append(column);

                doc.WorkSheet.InsertAt(columns, 0);
#endif
#if NO
                List<int> widths = new List<int>(new int [] {4,4,4,40});
                SetColumnWidth(doc, widths);
#endif
            }

            // 构造表格标题和标题行
            BuildTextPageTop(option,
                macro_table,
                sw,
                sheet);

            stop.SetProgressValue(0);
            stop.SetProgressRange(0, items.Count);

            // 表格行循环
            for (int i = 0; i < items.Count; i++)
            {
                Application.DoEvents();	// 出让界面控制权

                if (stop != null && stop.State != 0)
                {
                    strError = "用户中断";
                    return -1;
                }

                BuildTextTableLine(option,
                    items,
                    i,
                    sw,
                    // ref doc,
                    sheet,
                    this.TextTruncate);

                stop.SetProgressValue(i + 1);
            }

            return 0;
        }
Пример #3
0
        // 构造html页面
        int BuildHtml(
            List<ListViewItem> items,
            out List<string> filenames,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            Hashtable macro_table = new Hashtable();

            string strNamePath = "accountbook_printoption_html";

            // 获得打印参数
            PrintOption option = new AccountBookPrintOption(this.MainForm.DataDir,
                this.comboBox_load_type.Text);
            option.LoadData(this.MainForm.AppInfo,
                strNamePath);

            // 检查当前排序状态和包含种价格列之间是否存在矛盾
            if (bHasBiblioPriceColumn(option) == true)
            {

                if (this.SortColumns_in.Count != 0
                    && this.SortColumns_in[0].No == COLUMN_BIBLIORECPATH)
                {
                }
                else
                {
                    MessageBox.Show(this, "由于当前打印用到了 “种价格”列,为保证打印结果的准确,程序自动按 ‘种记录路径’ 列对全部列表事项进行一次自动排序。\r\n\r\n为避免这里的自动排序,可在打印前用鼠标左键点栏标题进行符合自己意愿的排序,只要最后一次点的是‘种记录路径’栏标题即可。");
                    ForceSortColumnsIn(COLUMN_BIBLIORECPATH);
                }


            }


            // 计算出页总数
            int nTablePageCount = items.Count / option.LinesPerPage;
            if ((items.Count % option.LinesPerPage) != 0)
                nTablePageCount++;

            int nPageCount = nTablePageCount + 1;

            // 2009/7/24 changed
            if (this.SourceStyle == "batchno")
            {
                // 2008/11/22 
                macro_table["%batchno%"] = HttpUtility.HtmlEncode(this.BatchNo); // 批次号
                macro_table["%location%"] = HttpUtility.HtmlEncode(this.LocationString); // 馆藏地点 用HtmlEncode()的原因是要防止里面出现的“<不指定>”字样
            }
            else
            {
                macro_table["%batchno%"] = "";
                macro_table["%location%"] = "";
            }

            macro_table["%pagecount%"] = nPageCount.ToString();
            macro_table["%linesperpage%"] = option.LinesPerPage.ToString();
            macro_table["%date%"] = DateTime.Now.ToLongDateString();

            // 2009/7/24 changed
            if (this.SourceStyle == "barcodefile")
            {
                macro_table["%barcodefilepath%"] = this.BarcodeFilePath;
                macro_table["%barcodefilename%"] = Path.GetFileName(this.BarcodeFilePath);
            }
            else
            {
                macro_table["%barcodefilepath%"] = "";
                macro_table["%barcodefilename%"] = "";
            }

            // 2009/7/30 
            if (this.SourceStyle == "recpathfile")
            {
                macro_table["%recpathfilepath%"] = this.RecPathFilePath;
                macro_table["%recpathfilename%"] = Path.GetFileName(this.RecPathFilePath);
            }
            else
            {
                Debug.Assert(this.SourceStyle == "batchno"
                    || this.SourceStyle == "barcodefile"
                    || this.SourceDescription == "",
                    "");

                macro_table["%recpathfilepath%"] = "";
                macro_table["%recpathfilename%"] = "";
            }

            macro_table["%sourcedescription%"] = this.SourceDescription;

            filenames = new List<string>();    // 每页一个文件,这个数组存放了所有文件名

            string strFileNamePrefix = Path.Combine(this.MainForm.DataDir, "~accountbook");

            string strFileName = "";

            // 输出统计信息页
            {
                int nItemCount = items.Count;
                int nBiblioCount = GetBiblioCount(items);
                string strTotalPrice = GetTotalPrice(items);

                macro_table["%itemcount%"] = nItemCount.ToString();
                macro_table["%bibliocount%"] = nBiblioCount.ToString();
                macro_table["%totalprice%"] = strTotalPrice;

                macro_table["%pageno%"] = "1";

                // 2008/11/23 
                macro_table["%datadir%"] = this.MainForm.DataDir;   // 便于引用datadir下templates目录内的某些文件
                ////macro_table["%libraryserverdir%"] = this.MainForm.LibraryServerDir;  // 便于引用服务器端的CSS文件
                // 2009/10/10 
                macro_table["%cssfilepath%"] = this.GetAutoCssUrl(option, "accountbook.css");  // 便于引用服务器端或“css”模板的CSS文件

                // strFileName = strFileNamePrefix + "0" + ".html";
                strFileName = strFileNamePrefix + "0-" + Guid.NewGuid().ToString()+ ".html";

                filenames.Add(strFileName);

                string strTemplateFilePath = option.GetTemplatePageFilePath("统计页");
                if (String.IsNullOrEmpty(strTemplateFilePath) == false)
                {
                    /*
<html>
<head>
	老用法<LINK href='%libraryserverdir%/accountbook.css' type='text/css' rel='stylesheet'>
	新用法<LINK href='%cssfilepath%' type='text/css' rel='stylesheet'>
</head>
<body>
	<div class='pageheader'>%date% 财产帐簿 -- %sourcedescription% -- (共 %pagecount% 页)</div>
	<div class='tabletitle'>%date% 财产帐簿 -- %barcodefilepath%</div>
	<div class='itemcount'>册数: %itemcount%</div>
	<div class='bibliocount'>种数: %bibliocount%</div>
	<div class='totalprice'>总价: %totalprice%</div>
	<div class='sepline'><hr/></div>
	<div class='batchno'>批次号: %batchno%</div>
	<div class='location'>馆藏地点: %location%</div>
	<div class='location'>条码号文件: %barcodefilepath%</div>
	<div class='location'>记录路径文件: %recpathfilepath%</div>
	<div class='sepline'><hr/></div>
	<div class='pagefooter'>%pageno%/%pagecount%</div>
</body>
</html>
                     * * */

                    // 根据模板打印
                    string strContent = "";
                    // 能自动识别文件内容的编码方式的读入文本文件内容模块
                    // return:
                    //      -1  出错
                    //      0   文件不存在
                    //      1   文件存在
                    nRet = Global.ReadTextFileContent(strTemplateFilePath,
                        out strContent,
                        out strError);
                    if (nRet == -1)
                        return -1;

                    string strResult = StringUtil.MacroString(macro_table,
                        strContent);
                    StreamUtil.WriteText(strFileName,
                        strResult);
                }
                else
                {
                    // 缺省的固定内容打印

                    BuildHtmlPageTop(option,
                        macro_table,
                        strFileName,
                        false);

                    // 内容行

                    StreamUtil.WriteText(strFileName,
                        "<div class='itemcount'>册数: " + nItemCount.ToString() + "</div>");
                    StreamUtil.WriteText(strFileName,
                        "<div class='bibliocount'>种数: " + nBiblioCount.ToString() + "</div>");
                    StreamUtil.WriteText(strFileName,
                        "<div class='totalprice'>总价: " + strTotalPrice + "</div>");

                    StreamUtil.WriteText(strFileName,
                        "<div class='sepline'><hr/></div>");


                    if (this.SourceStyle == "batchno")
                    {

                        // 2008/11/22 
                        if (String.IsNullOrEmpty(this.BatchNo) == false)
                        {
                            StreamUtil.WriteText(strFileName,
                                "<div class='batchno'>批次号: " + this.BatchNo + "</div>");
                        }
                        if (String.IsNullOrEmpty(this.LocationString) == false
                            && this.LocationString != "<不指定>")
                        {
                            StreamUtil.WriteText(strFileName,
                                "<div class='location'>馆藏地点: " + this.LocationString + "</div>");
                        }
                    }


                    if (this.SourceStyle == "barcodefile")
                    {
                        if (String.IsNullOrEmpty(this.BarcodeFilePath) == false)
                        {
                            StreamUtil.WriteText(strFileName,
                                "<div class='barcodefilepath'>条码号文件: " + this.BarcodeFilePath + "</div>");
                        }
                    }

                    // 2009/7/30
                    if (this.SourceStyle == "recpathfile")
                    {
                        if (String.IsNullOrEmpty(this.RecPathFilePath) == false)
                        {
                            StreamUtil.WriteText(strFileName,
                                "<div class='recpathfilepath'>记录路径文件: " + this.RecPathFilePath + "</div>");
                        }
                    }

                    /*
                    StreamUtil.WriteText(strFileName,
                        "<div class='sepline'><hr/></div>");


                    StreamUtil.WriteText(strFileName,
                        "<div class='sender'>移交者: </div>");
                    StreamUtil.WriteText(strFileName,
                        "<div class='recipient'>接受者: </div>");
                     * */


                    BuildHtmlPageBottom(option,
                        macro_table,
                        strFileName,
                        false);
                }

            }


            string strMarcFilterFilePath = option.GetTemplatePageFilePath("MARC过滤器");
            if (String.IsNullOrEmpty(strMarcFilterFilePath) == false)
            {
#if NO
                ColumnFilterDocument filter = null;

                this.ColumnTable = new Hashtable();
                nRet = PrepareMarcFilter(strMarcFilterFilePath,
                    out filter,
                    out strError);
                if (nRet == -1)
                    return -1;

                //
                if (filter != null)
                    this.AssemblyFilter = filter.Assembly;
                else
                    this.AssemblyFilter = null;

                this.MarcFilter = filter;
#endif
                nRet = PrepareMarcFilter(strMarcFilterFilePath, out strError);
                if (nRet == -1)
                    return -1;
            }


            // 表格页循环
            for (int i = 0; i < nTablePageCount; i++)
            {
                macro_table["%pageno%"] = (i + 1 + 1).ToString();

                // strFileName = strFileNamePrefix + (i + 1).ToString() + ".html";
                strFileName = strFileNamePrefix + (i + 1).ToString() + "-" + Guid.NewGuid().ToString() + ".html";

                filenames.Add(strFileName);

                BuildHtmlPageTop(option,
                    macro_table,
                    strFileName,
                    true);
                // 行循环
                for (int j = 0; j < option.LinesPerPage; j++)
                {
                    BuildHtmlTableLine(option,
                        items,
                        strFileName, i, j);
                }

                BuildHtmlPageBottom(option,
                    macro_table,
                    strFileName,
                    true);
            }

            /*
            for (int i = 0; i < this.listView_in.Items.Count; i++)
            {

            }
             * */


            return 0;
        }
Пример #4
0
        // 输出到Word Xml文件
        int OutputToWordXmlFile(
            List<ListViewItem> items,
            XmlTextWriter writer,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            Hashtable macro_table = new Hashtable();

            string strNamePath = "accountbook_printoption_wordxml";

            // 获得打印参数
            PrintOption option = new AccountBookPrintOption(this.MainForm.DataDir,
                this.comboBox_load_type.Text);
            option.LoadData(this.MainForm.AppInfo,
                strNamePath);

            // 检查当前排序状态和包含种价格列之间是否存在矛盾
            if (bHasBiblioPriceColumn(option) == true)
            {

                if (this.SortColumns_in.Count != 0
                    && this.SortColumns_in[0].No == COLUMN_BIBLIORECPATH)
                {
                }
                else
                {
                    MessageBox.Show(this, "由于当前打印用到了 “种价格”列,为保证打印结果的准确,程序自动按 ‘种记录路径’ 列对全部列表事项进行一次自动排序。\r\n\r\n为避免这里的自动排序,可在打印前用鼠标左键点栏标题进行符合自己意愿的排序,只要最后一次点的是‘种记录路径’栏标题即可。");
                    ForceSortColumnsIn(COLUMN_BIBLIORECPATH);
                }
            }

            // 2009/7/24 changed
            if (this.SourceStyle == "batchno")
            {
                macro_table["%batchno%"] = HttpUtility.HtmlEncode(this.BatchNo); // 批次号
                macro_table["%location%"] = HttpUtility.HtmlEncode(this.LocationString); // 馆藏地点 用HtmlEncode()的原因是要防止里面出现的“<不指定>”字样
            }
            else
            {
                Debug.Assert(this.SourceStyle == "barcodefile"
                    || this.SourceStyle == "recpathfile"
                    || this.SourceStyle == "",
                    "");

                macro_table["%batchno%"] = "";
                macro_table["%location%"] = "";
            }

            // macro_table["%pagecount%"] = nPageCount.ToString();
            // macro_table["%linesperpage%"] = option.LinesPerPage.ToString();
            macro_table["%date%"] = DateTime.Now.ToLongDateString();

            // 2009/7/24 changed
            if (this.SourceStyle == "barcodefile")
            {
                macro_table["%barcodefilepath%"] = this.BarcodeFilePath;
                macro_table["%barcodefilename%"] = Path.GetFileName(this.BarcodeFilePath);
            }
            else
            {
                Debug.Assert(this.SourceStyle == "batchno"
                    || this.SourceStyle == "recpathfile"
                    || this.SourceStyle == "",
                    "");

                macro_table["%barcodefilepath%"] = "";
                macro_table["%barcodefilename%"] = "";
            }

            // 2009/7/30 
            if (this.SourceStyle == "recpathfile")
            {
                macro_table["%recpathfilepath%"] = this.RecPathFilePath;
                macro_table["%recpathfilename%"] = Path.GetFileName(this.RecPathFilePath);
            }
            else
            {
                Debug.Assert(this.SourceStyle == "batchno"
                    || this.SourceStyle == "barcodefile"
                    || this.SourceStyle == "",
                    "");

                macro_table["%recpathfilepath%"] = "";
                macro_table["%recpathfilename%"] = "";
            }

            macro_table["%sourcedescription%"] = this.SourceDescription;

            WriteWordXmlHead(writer);

            // 输出统计信息页
            if (this.WordXmlOutputStatisPart == true)
            {
                int nItemCount = items.Count;
                int nBiblioCount = GetBiblioCount(items);
                string strTotalPrice = GetTotalPrice(items);

                macro_table["%itemcount%"] = nItemCount.ToString();
                macro_table["%bibliocount%"] = nBiblioCount.ToString();
                macro_table["%totalprice%"] = strTotalPrice;

                macro_table["%pageno%"] = "1";

                // 2008/11/23 
                macro_table["%datadir%"] = this.MainForm.DataDir;   // 便于引用datadir下templates目录内的某些文件
                ////macro_table["%libraryserverdir%"] = this.MainForm.LibraryServerDir;  // 便于引用服务器端的CSS文件

                string strTemplateFilePath = option.GetTemplatePageFilePath("统计页");
                if (String.IsNullOrEmpty(strTemplateFilePath) == false)
                {
                    /*
%date% 财产帐簿 -- %sourcedescription%
册数: %itemcount%
种数: %bibliocount%
总价: %totalprice%
------------
批次号: %batchno%
馆藏地点: %location%
条码号文件: %barcodefilepath%
记录路径文件: %recpathfilepath%
                     * * */

                    // 根据模板打印
                    string strContent = "";
                    // 能自动识别文件内容的编码方式的读入文本文件内容模块
                    // return:
                    //      -1  出错
                    //      0   文件不存在
                    //      1   文件存在
                    nRet = Global.ReadTextFileContent(strTemplateFilePath,
                        out strContent,
                        out strError);
                    if (nRet == -1)
                        return -1;

                    string strResult = StringUtil.MacroString(macro_table,
                        strContent);
                    string[] lines = strResult.Split(new string[] {"\r\n"},
                        StringSplitOptions.None);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        WriteParagraph(writer, lines[i]);
                    }
                }
                else
                {
                    // 缺省的固定内容打印

                    /*
                    BuildPageTop(option,
                        macro_table,
                        strFileName,
                        false);
                     * */

                    // 内容行

                    WriteParagraph(writer, "册数\t" + nItemCount.ToString());
                    WriteParagraph(writer, "种数\t" + nBiblioCount.ToString());
                    WriteParagraph(writer, "总价\t" + strTotalPrice);

                    WriteParagraph(writer, "----------");


                    if (this.SourceStyle == "batchno")
                    {
                        // 2008/11/22 
                        if (String.IsNullOrEmpty(this.BatchNo) == false)
                        {
                            WriteParagraph(writer, "批次号\t" + this.BatchNo);
                        }
                        if (String.IsNullOrEmpty(this.LocationString) == false
                            && this.LocationString != "<不指定>")
                        {
                            WriteParagraph(writer, "馆藏地点\t" + this.LocationString);
                        }
                    }

                    if (this.SourceStyle == "barcodefile")
                    {
                        if (String.IsNullOrEmpty(this.BarcodeFilePath) == false)
                        {
                            WriteParagraph(writer, "条码号文件\t" + this.BarcodeFilePath);
                        }
                    }

                    // 2009/7/30 
                    if (this.SourceStyle == "recpathfile")
                    {
                        if (String.IsNullOrEmpty(this.RecPathFilePath) == false)
                        {
                            WriteParagraph(writer, "记录路径文件\t" + this.RecPathFilePath);
                        }
                    }

                    WriteParagraph(writer, "----------");
                    WriteParagraph(writer, "");
                }
            }

            string strMarcFilterFilePath = option.GetTemplatePageFilePath("MARC过滤器");
            if (String.IsNullOrEmpty(strMarcFilterFilePath) == false)
            {
#if NO
                ColumnFilterDocument filter = null;

                this.ColumnTable = new Hashtable();
                nRet = PrepareMarcFilter(strMarcFilterFilePath,
                    out filter,
                    out strError);
                if (nRet == -1)
                    return -1;

                //
                if (filter != null)
                    this.AssemblyFilter = filter.Assembly;
                else
                    this.AssemblyFilter = null;

                this.MarcFilter = filter;
#endif
                nRet = PrepareMarcFilter(strMarcFilterFilePath, out strError);
                if (nRet == -1)
                    return -1;
            }

            // 构造表格标题和标题行
            WriteTableBegin(writer,
                option,
                macro_table);

            // 表格行循环
            for (int i = 0; i < items.Count; i++)
            {
                BuildWordXmlTableLine(option,
                    items,
                    i,
                    writer,
                    this.WordXmlTruncate);
            }

            WriteTableEnd(writer);

            WriteWordXmlTail(writer);

            return 0;
        }