Beispiel #1
0
        /// <summary>
        /// 显示Cell文件
        /// </summary>
        /// <param name="fileID">文件ID</param>
        private void showCell(string fileID)
        {
            // string fileID = e.Node.Name;
            IList <MDL.T_CellAndEFile> cellAndEFile_List =
                (new BLL.T_CellAndEFile_BLL()).FindByFileID(fileID, Globals.ProjectNO);

            if (cellAndEFile_List != null && cellAndEFile_List.Count > 0)
            {
                string filePath = cellAndEFile_List[0].filepath;
                if (filePath != null && filePath.Length > 0 && filePath.IndexOf(".cll") > -1)
                {
                    int retValue = Cell2.OpenFile(string.Concat(Globals.ProjectPath, filePath), "");
                    Cell2.HScrollHeight = 1;
                    //Cell2.VScrollWidth = 0;
                    if (Cell2.GetTotalSheets() > 1)
                    {
                        Cell2.SetCurSheet(0);
                    }
                }
                else
                {
                    IList <MDL.T_CellFileTemplate> cellFileTemplate_List =
                        (new BLL.T_CellFileTemplate_BLL()).FindByFileID(fileID);
                    if (cellFileTemplate_List != null && cellFileTemplate_List.Count > 0 &&
                        cellFileTemplate_List[0].filepath != null && cellFileTemplate_List[0].filepath.Length > 0)
                    {
                        int retValue = Cell2.OpenFile(string.Concat(Application.StartupPath, "\\", "Template", cellFileTemplate_List[0].filepath), "");
                        //Cell2.AutoScrollOffset = 1;
                        //Cell2.VScrollWidth = 0;
                        if (Cell2.GetTotalSheets() > 1)
                        {
                            Cell2.SetCurSheet(0);
                        }
                    }
                    else
                    {
                        Cell2.OpenFile(Globals.BlankCell, "");
                    }
                }
            }
            else
            {
                Cell2.OpenFile(Globals.BlankCell, "");
            }
        }
Beispiel #2
0
 /// <summary>
 /// 初始化详细过程
 /// </summary>
 public void Init()
 {
     try
     {
         Cell2.WorkbookReadonly = true;
         this.Text      = "工程资料用表 - " + Globals.Projectname; //窗体标题
         tssLabel1.Text = Globals.NormalStatus;              //状态栏:就绪
         tssLabel2.Text = Globals.AppTitle;                  //状态栏:应用程序标题
         tssLabel3.Text = "当前用户:" + Globals.LoginUser;       //状态栏:当前用户
         ImageList imageList1 = treeFactory.CreateTreeImageList();
         treeView1.ImageList = imageList1;
         treeFactory.GetTree(treeView1, Globals.ProjectNO, "", true, true, 1, true);
         Cell2.OpenFile(Globals.BlankCell, "");
         listView1.LargeImageList = imageList1;
         listView1.SmallImageList = imageList1;
     }
     catch
     {
     }
 }
Beispiel #3
0
        public int PrintCellToPDF(string cellFileName, string outFileName)
        {
            if (!System.IO.File.Exists(cellFileName))
            {
                return(0);
            }

            string FileExt = System.IO.Path.GetExtension(cellFileName);//文件后缀

            try
            {
                if (FileExt.ToLower() != ".cll")
                {
                    if (FileExt.ToLower() == ".pdf" ||
                        FileExt.ToLower() == ".daf")
                    {
                        System.IO.File.Copy(cellFileName, outFileName, true);
                        return(this.MergePDFFilesPages(outFileName));
                    }
                    else
                    {
                        if (this.FileConverToPDF(cellFileName, outFileName))
                        {
                            return(this.MergePDFFilesPages(outFileName));
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MyCommon.WriteLog("50cllPdf 转换pdf异常:" + ex.Message);
            }
            //System.Collections.ArrayList fileList = new System.Collections.ArrayList();
            //Cell2.SetPrinter(PrinterOperate.UsePrinterName);
            //Cell2.PrintPara(1, 1, 0, 0); //单色打印

            if (System.IO.Directory.Exists(tempPath))
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempPath, false);
                MyCommon.DeleteAndCreateEmptyDirectory(tempPath, true);
            }
            else
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempPath, true);
            }

            ArrayList fileList = new ArrayList();

            try
            {
                if (Cell2.OpenFile(cellFileName, "") != 1)
                {
                    return(0);
                }

                Cell2.PrintSetAlign(1, 1);
                Cell2.PrintSetMargin(5, 5, 5, 5);
                Cell2.PrintPara(1, 1, 0, 0); //单色打印
                //Cell2.SetCurSheet(j);
                //Cell2.PrintPageBreak(0);
            }
            catch (Exception ex)
            {
                MyCommon.WriteLog("Cell2 打开错误:" + ex.Message);
            }
            //判断当前页 所有的单元是否只读
            // 如果当前页的所有单元格只读,就不转换PDF
            // 否则 就直接转换PDF
            Assembly asm     = Assembly.GetExecutingAssembly();
            string   AppPath = asm.Location;

            try
            {
                bool isToPDF_flg = true;
                for (int j = 0; j < Cell2.GetTotalSheets(); j++)
                {
                    Cell2.SetCurSheet(j);
                    string TittleName = Cell2.GetSheetLabel(j);
                    if (TittleName != null)
                    {
                        if (TittleName.Contains("填表提示") || TittleName.Contains("填表说明") || TittleName.Trim() == "说明")//
                        {
                            continue;
                        }
                    }

                    string tempoutfileName = Guid.NewGuid().ToString() + ".pdf";
                    isToPDF_flg = true;
                    for (int iRow = 1; iRow < Cell2.GetRows(j) - 1; iRow++)
                    {
                        if (!isToPDF_flg)
                        {
                            break;
                        }
                        if (Cell2.IsRowHidden(iRow, j) == false && Cell2.GetRowHeight(1, iRow, j) > 10)
                        {
                            for (int iCol = 1; iCol < Cell2.GetCols(j) - 1; iCol++)
                            {
                                if (!isToPDF_flg)
                                {
                                    break;
                                }
                                if (Cell2.IsColHidden(iCol, j) == false && Cell2.GetColWidth(1, iCol, j) > 10)
                                {
                                    if (Cell2.GetCellInput(iCol, iRow, j) != 5)
                                    {
                                        isToPDF_flg = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if ((!isToPDF_flg))
                    {
                        //ConverToPDF.PreparePrint(Assembly.GetExecutingAssembly().FullName, "", tempPath + tempoutfileName);
                        //Cell2.PrintSheet(0, j);
                        //ConverToPDF.Wait4PringFinish("", tempPath + tempoutfileName);
                        if (Cell2.ExportPdfFile(tempPath + tempoutfileName, j, 0, 1))
                        {
                            fileList.Add(tempPath + tempoutfileName);
                        }
                    }
                }
                Cell2.closefile();
            }
            catch (Exception ex)
            {
                MyCommon.WriteLog("Cell2 转换PDF错误:" + ex.Message);
            }
            #region

            /*
             * //Cell2.ExportPdfFile(tempPath + tempoutfileName, -1, 0, Cell2.GetTotalSheets());
             *
             *
             * //for (int j = 0; j < Cell2.GetTotalSheets(); j++)
             * //{
             * //    string TittleName = Cell2.GetSheetLabel(j);
             * //    if (!TittleName.Contains(Globals.Descriptive))
             * //    {
             * //        fileList.Add(tempFile + j.ToString() + ".pdf");
             * //        outFile = tempFile + j.ToString() + ".pdf";
             * //        NewPrint();
             * //        oPrinterMonitor.OnPrinterInit += new _IPrinterMonitorEvents_OnPrinterInitEventHandler(oPrinterMonitor_OnPrinterInit);
             * //        Cell2.PrintSheet(0, j);
             * //        oPrinterMonitor.OnPrinterInit -= new _IPrinterMonitorEvents_OnPrinterInitEventHandler(oPrinterMonitor_OnPrinterInit);
             * //        Application.DoEvents();
             * //    }
             * //}
             *
             * //foreach (object obj in fileList)
             * //{
             * //    if(!System.IO.File.Exists(obj.ToString()))
             * //    {
             * //        fileList.Remove(obj);
             * //    }
             * //}
             * //if (fileList.Count <= 0)
             * //{
             * //    return 0;
             * //}
             * */
            #endregion
            string[] FileName = new string[fileList.Count];
            for (int i = 0; i < fileList.Count; i++)
            {
                FileName[i] = fileList[i].ToString();
            }
            if (FileName.Length <= 0)
            {
                return(0);
            }
            return(MergePDFFilesPages(outFileName));
        }
Beispiel #4
0
        private bool Printcells(string filepath, string printerName)
        {
            int b = Cell2.OpenFile(filepath, "");

            if (b != 1)
            {
                return(false);
            }

            Cell2.PrintSetAlign(1, 1);
            Cell2.PrintSetMargin(5, 5, 5, 5);

            //判断当前页 所有的单元是否只读
            // 如果当前页的所有单元格只读,就不转换PDF
            // 否则 就直接转换PDF
            bool isToPDF_flg = true;

            for (int j = 0; j < Cell2.GetTotalSheets(); j++)
            {
                Cell2.SetCurSheet(j);
                string TittleName = Cell2.GetSheetLabel(j);
                if (TittleName != null &&
                    TittleName.Contains("填表提示"))//
                {
                    continue;
                }

                isToPDF_flg = true;
                for (int iRow = 1; iRow < Cell2.GetRows(j) - 1; iRow++)
                {
                    if (!isToPDF_flg)
                    {
                        break;
                    }
                    if (Cell2.IsRowHidden(iRow, j) == false && Cell2.GetRowHeight(1, iRow, j) > 10)
                    {
                        for (int iCol = 1; iCol < Cell2.GetCols(j) - 1; iCol++)
                        {
                            if (!isToPDF_flg)
                            {
                                break;
                            }
                            if (Cell2.IsColHidden(iCol, j) == false && Cell2.GetColWidth(1, iCol, j) > 10)
                            {
                                if (Cell2.GetCellInput(iCol, iRow, j) != 5)
                                {
                                    isToPDF_flg = false;
                                    break;
                                }
                            }
                        }
                    }
                }
                if ((!isToPDF_flg))
                {
                    Cell2.PrintSheet(0, j);
                }
            }
            Cell2.closefile();
            return(true);
        }