Пример #1
0
        public bool InsertExcel(string titleName, string unit, GridControl gridControl, TONLI.BZH.UI.DSOFramerWordControl wordcontrol)
        {
            try
            {
                System.Drawing.Font font = new System.Drawing.Font("���ו", 16);
                wordcontrol.DoInsert("\n\n"+titleName+"\n"  , font, TONLI.BZH.UI.WdParagraphAlignment.Center);
                //wordcontrol.DoPaste();

                font = new System.Drawing.Font("���ו", 12);
                wordcontrol.DoInsert(unit + "\n", font, TONLI.BZH.UI.WdParagraphAlignment.Right);
                //wordcontrol.DoPaste();

                wordcontrol.DoInsert("", font, TONLI.BZH.UI.WdParagraphAlignment.Center);
                string filename =System.Windows.Forms.Application.StartupPath + "\\BlogData\\Blog.xls";
                gridControl.DefaultView.ExportToExcelOld(filename);

                wordcontrol.DoInsertOleObject(filename);
                //System.Drawing.Font font = new System.Drawing.Font("���ו", 16);
                wordcontrol.DoInsert("", font, TONLI.BZH.UI.WdParagraphAlignment.Center);
                //Microsoft.Office.Interop.Excel.Application ep = new Microsoft.Office.Interop.Excel.Application();

                //Microsoft.Office.Interop.Excel._Workbook wb = ep.Workbooks.Add(filename);

                //Microsoft.Office.Interop.Excel.Sheets sheets = wb.Worksheets;

                //Microsoft.Office.Interop.Excel._Worksheet ws = (Microsoft.Office.Interop.Excel._Worksheet)sheets.get_Item(1);// [System.Type.Missing];//.get.get_Item("xx");
                //ws.UsedRange.Select();
                //ws.UsedRange.Copy(System.Type.Missing);

                //wordcontrol.DoPaste();

                return true;
            }
            catch { return false; }
        }