• Excel不同表格间复制的问题


    如果要在不同表格间复制worksheet,前提必须是同一个workbooks打开的,否则会报0x800A03EC的错误。

                bool vFG = true;

                m_App.Visible = false;
                //m_App1.Visible = false;

                m_App.DisplayAlerts = false;
                //m_App1.DisplayAlerts = false;

                Workbooks vWorkbooks = m_App.Application.Workbooks;
                //Workbooks vWorkbooks1 = m_App1.Application.Workbooks;

                object vReadOnly = false;
                object vEditable = true;


       Workbook vWorkbook = vWorkbooks.Open( pFileName, m_Missing, vReadOnly, m_Missing, m_Missing, m_Missing, m_Missing, m_Missing, m_Missing, vEditable, m_Missing, m_Missing, m_Missing, m_Missing,m_Missing);

                bool vExist = false;

                for (int i = 1; i <= vWorkbook.Worksheets.Count; i++)
                {
                    Worksheet vWorksheet = (Worksheet)vWorkbook.Worksheets[i];
                    if (vWorksheet.Name.Equals("B票"))
                    {
                        vExist = true;
                        break;
                    }
                }

                if (!vExist)
                {
                    if (this.m_WorkSheetOfMode == null)
                    {

                        Workbook vWorkbook1 = vWorkbooks.Open(this.txtModeOfBugList.Text, m_Missing, vReadOnly, m_Missing, m_Missing, m_Missing, m_Missing, m_Missing, m_Missing, vEditable, m_Missing, m_Missing, m_Missing, m_Missing,m_Missing);

                        Worksheet vWorksheet1 = null;

                        for (int i = 1; i <= vWorkbook1.Worksheets.Count; i++)
                        {
                            vWorksheet1 = (Worksheet)vWorkbook1.Worksheets[i];
                            if (vWorksheet1.Name.Equals("B票"))
                            {
                                vExist = true;

                                this.m_WorkSheetOfMode = vWorksheet1;

                                break;
                            }
                        }

                        if (!vExist)
                        {
                            vFG = false;
                        }
                        else
                        {
                            Worksheet vWorksheet2 = (Worksheet)vWorkbook.Worksheets[vWorkbook.Worksheets.Count];
                           
                            vWorksheet1.Copy(m_Missing, vWorksheet2);
                        }
                    }
                    else
                    {
                        Worksheet vWorksheet2 = (Worksheet)vWorkbook.Worksheets[vWorkbook.Worksheets.Count];
                        this.m_WorkSheetOfMode.Copy(m_Missing, vWorksheet2);
                    }
                }

                vWorkbook.Save();
                //vWorkbooks1[1].Save();

                vWorkbooks.Close();

                vWorkbooks = null;

                //vWorkbooks1.Close();
                m_App.Quit();
                //m_App1.Quit();

  • 相关阅读:
    linux超级终端minicom的使用方法
    linux常用命令
    chmod 777 修改权限
    linux mount挂载设备(u盘,光盘,iso等 )使用说明
    logcat的调试 比较有用的几个命令
    git分支
    Debug和Release区别
    【Linux】linux常用基本命令
    Git代码仓库的建立流程
    Linux记录-JMX监控Tomcat上传到falcon
  • 原文地址:https://www.cnblogs.com/si812cn/p/1315022.html
Copyright © 2020-2023  润新知