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
            {

            }
        }