Пример #1
0
        private void OnExport(object sender, EventArgs e)
        {
            int            num    = Convert.ToInt32(PPMCommon.GetRegistryKey());
            SaveFileDialog dialog = new SaveFileDialog {
                Title    = "当前页导出为Excel文件",
                FileName = @"C:\" + this.m_tp.TemplateID
            };
            string str  = "所有文件 (*.*)|*.*";
            string str2 = ".xls";

            if (num < 12)
            {
                str = "Excel工作簿 (*.xls)|*.xls|" + str;
            }
            else
            {
                str  = "Excel工作簿 (*.xlsx)|*.xlsx|Excel 97-2003 工作簿 (*.xls)|*.xls|" + str;
                str2 = ".xlsx";
            }
            dialog.Filter     = str;
            dialog.DefaultExt = str2;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Cursor current = Cursor.Current;
                Cursor.Current = Cursors.WaitCursor;
                try {
                    this.Export(dialog.FileName);
                    this.m_tp.IsSaved = false;
                } catch (Exception exception) {
                    MessageBox.Show("导出到Excel文档失败,请重试。\n" + exception.Message, "PPM", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                } finally {
                    Cursor.Current = current;
                }
            }
        }
Пример #2
0
        private void OnImport(object sender, EventArgs e)
        {
            int    num = Convert.ToInt32(PPMCommon.GetRegistryKey());
            string str = "HTML文件 (*.htm;*.html)|*.htm;*.html|所有文件 (*.*)|*.*";

            if (num < 12)
            {
                str = "Excel工作簿 (*.xls)|*.xls|" + str;
            }
            else
            {
                str = "Excel工作簿 (*.xlsx)|*.xlsx|Excel 97-2003 工作簿 (*.xls)|*.xls|" + str;
            }
            OpenFileDialog dialog = new OpenFileDialog {
                Title  = "请您选择文件",
                Filter = str
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string str2 = Path.GetExtension(dialog.FileName).ToLower();
                if (((num >= 12) && ((str2 == ".xls") || (str2 == ".xlsx"))) || ((num < 12) && (str2 == ".xls")))
                {
                    ArrayList list;
                    Cursor    current = Cursor.Current;
                    Cursor.Current = Cursors.WaitCursor;
                    try {
                        if (OfficeWrap.Instance == null)
                        {
                            OfficeWrap.Instance = new OfficeWrap();
                        }
                        list = OfficeWrap.Instance.Import(dialog.FileName, BizOperationHelper.Instance.GetTempFilePath());
                    } catch (Exception exception) {
                        MessageBox.Show(exception.Message, "PPM - FrmPPCard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    } finally {
                        Cursor.Current = current;
                    }
                    PPTmpPage tmpPage = this.GetTmpPage(base.SelectedTab.Text);
                    if (list.Count > 0)
                    {
                        tmpPage.TemplateUrl = (string)list[0];
                        this.m_tp.IsSaved   = false;
                    }
                }
                else
                {
                    this.GetTmpPage(base.SelectedTab.Text).TemplateUrl = dialog.FileName;
                    this.m_tp.IsSaved = false;
                }
            }
        }
Пример #3
0
        private void PrintPreview()
        {
            PPTmpPage tmpPage = this.GetTmpPage(base.SelectedTab.Text);

            Convert.ToInt32(PPMCommon.GetRegistryKey());
            string exportFileName = BizOperationHelper.Instance.GetTempFilePath() + base.SelectedTab.Text + ".xls";

            tmpPage.Export(exportFileName, false);
            if (OfficeWrap.Instance == null)
            {
                OfficeWrap.Instance = new OfficeWrap();
            }
            OfficeWrap.Instance.SetupPages(this.m_tp.PageSetup);
            OfficeWrap.Instance.PrintPreview(exportFileName);
        }