Example #1
0
        private void barButtonItem30_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm wait = null;
            WordBuilder wb = new WordBuilder();
            wb.InsertFromFile("Very.doc");

            //TONLI.BZH.UI.DSOFramerWordControl wb = new DSOFramerWordControl();
            try
            {
                wait = new WaitDialogForm("", "���ڵ���, ���Ժ�...");

                IList<LayoutContent> ls = Services.BaseService.GetList<LayoutContent>("SelectLayoutContentByLayoutIDBlogData", layoutUID);
                System.Data.DataTable dts = DataConverter.ToDataTable((IList)ls, typeof(LayoutContent));

                //IList<byte[]> lbt = new List<byte[]>();

                IList<LayoutContent> lbt = new List<LayoutContent>();

                InitExe("", dts, lbt);
                GetTop(layoutUID + "|1", wb);

                object obj = "���� 1";

                Style testStyle = wb.wordApp.Application.ActiveDocument.Styles.get_Item(ref obj);
                object listObject = testStyle;
                wb.wordApp.Selection.set_Style(ref listObject);

                InitAdd(lbt, wb);
                GetTop(layoutUID + "|2", wb);

                //IList<LayoutContent> lbt = new List<LayoutContent>();
                //InitExe("", dts, lbt);
                //GetTop(layoutUID + "|1", wb);
                //InitAdd(lbt, wb);
                //GetTop(layoutUID + "|2", wb);
            }
            catch
            {
                wb.Dispose();
                wait.Close();
                MsgBox.Show("����ʧ��");
                return;
            }
            wait.Close();

            string fname = "";
            saveFileDialog1.Filter = "Microsoft word (*.doc)|*.doc";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {

                fname = saveFileDialog1.FileName;
                wb.Save(fname, true);
                wb.Dispose();
                if (MsgBox.ShowYesNo("�����ɹ����Ƿ�򿪸��ĵ���") != DialogResult.Yes)
                    return;
                try
                {
                    System.Diagnostics.Process.Start(fname);
                }
                catch { }
            }
            else
            {

            }
        }
Example #2
0
        private void barButtonItem30_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm wait = null;
            WordBuilder    wb   = new WordBuilder();

            wb.InsertFromFile("Very.doc");


            //TONLI.BZH.UI.DSOFramerWordControl wb = new DSOFramerWordControl();
            try
            {
                wait = new WaitDialogForm("", "正在导出, 请稍候...");


                IList <LayoutContent> ls  = Services.BaseService.GetList <LayoutContent>("SelectLayoutContentByLayoutIDBlogData", layoutUID);
                System.Data.DataTable dts = DataConverter.ToDataTable((IList)ls, typeof(LayoutContent));

                //IList<byte[]> lbt = new List<byte[]>();



                IList <LayoutContent> lbt = new List <LayoutContent>();

                InitExe("", dts, lbt);
                GetTop(layoutUID + "|1", wb);


                object obj = "标题 1";


                Style  testStyle  = wb.wordApp.Application.ActiveDocument.Styles.get_Item(ref obj);
                object listObject = testStyle;
                wb.wordApp.Selection.set_Style(ref listObject);



                InitAdd(lbt, wb);
                GetTop(layoutUID + "|2", wb);


                //IList<LayoutContent> lbt = new List<LayoutContent>();
                //InitExe("", dts, lbt);
                //GetTop(layoutUID + "|1", wb);
                //InitAdd(lbt, wb);
                //GetTop(layoutUID + "|2", wb);
            }
            catch
            {
                wb.Dispose();
                wait.Close();
                MsgBox.Show("导出失败");
                return;
            }
            wait.Close();

            string fname = "";

            saveFileDialog1.Filter = "Microsoft word (*.doc)|*.doc";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                fname = saveFileDialog1.FileName;
                wb.Save(fname, true);
                wb.Dispose();
                if (MsgBox.ShowYesNo("导出成功,是否打开该文档?") != DialogResult.Yes)
                {
                    return;
                }
                try
                {
                    System.Diagnostics.Process.Start(fname);
                }
                catch { }
            }
            else
            {
            }
        }