void gridViewOperation_AfterAdd(PJ_24 e) { DSOFramerControl dsoFramerControl1 = new DSOFramerControl(); Microsoft.Office.Interop.Excel.Workbook wb;dsoFramerControl1.FileData = e.BigData; wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; ea.SetCellValue(ParentObj.OrgName , 4, 9); dsoFramerControl1.FileSave(); e.BigData = dsoFramerControl1.FileData; dsoFramerControl1.FileClose(); dsoFramerControl1.Dispose(); dsoFramerControl1 = null; }
public void ExportExceljhbAllSubmit(ref LP_Temple parentTemple, string cellname, string sheetname, string orgid, bool isShow) { DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string fname = Application.StartupPath + "\\00记录模板\\预防性试验记录.xls"; dsoFramerWordControl1.FileOpen(fname); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent; ExcelAccess ex = new ExcelAccess(); Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; ex.MyWorkBook = wb; ex.MyExcel = wb.Application; ExportExceljhbAllEx(ex, cellname, sheetname, orgid, isShow); string filter = ""; int i = 0; if (orgid != "") filter = " and OrgCode='" + orgid + "'"; if (isWorkflowCall) { filter = filter + " and ( id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where " + " WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "'" + ") or id in (select ModleRecordID from WF_ModleRecordWorkTaskIns where " + " RecordID='" + currRecord.ID + "'))"; } List<WF_ModleRecordWorkTaskIns> mrwtlist = new List<WF_ModleRecordWorkTaskIns>(); IList<PJ_yfsyjl> byqdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='变压器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); Export11.ExportExcelbyqEx(ex, byqdatalist, "变压器预防性试验记录", orgid, isShow); // IList<PJ_yfsyjl> byqjhbdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='变压器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); IList<PJ_yfsyjl> byqjhbdatalist = byqdatalist; Export11.ExportExcelbyqjhbEx(ex, byqdatalist, "变压器" + "预防性试验计划表", orgid, isShow); if (currRecord.Status != "申报") { Export11.ExportExcelbyqssqkEx(ex, byqdatalist, "变压器" + "预防性试验实施情况记录", orgid, isShow); Export11.ExportExcelbyqwcqkEx(ex, byqdatalist, "变压器" + "预防性试验完成情况报表", orgid, isShow); } byqdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='断路器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); Export11.ExportExceldlqEx(ex, byqdatalist, "断路器" + "预防性试验记录", orgid, isShow); //byqjhbdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='断路器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); byqjhbdatalist = byqdatalist; Export11.ExportExceldlqjhbEx(ex, byqdatalist, "断路器" + "预防性试验计划表", orgid, isShow); if (currRecord.Status != "申报") { Export11.ExportExceldlqssqkEx(ex, byqdatalist, "断路器" + "预防性试验实施情况记录", orgid, isShow); Export11.ExportExceldlqwcqkEx(ex, byqdatalist, "断路器" + "预防性试验完成情况报表", orgid, isShow); } byqdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='避雷器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); Export11.ExportExcelblqEx(ex, byqdatalist, "避雷器" + "预防性试验记录", orgid, isShow); //byqjhbdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='避雷器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); byqjhbdatalist = byqdatalist; Export11.ExportExcelblqjhbEx(ex, byqdatalist, "避雷器" + "预防性试验计划表", orgid, isShow); if (currRecord.Status != "申报") { Export11.ExportExcelblqssqkEx(ex, byqdatalist, "避雷器" + "预防性试验实施情况记录", orgid, isShow); Export11.ExportExcelblqwcqkEx(ex, byqdatalist, "避雷器" + "预防性试验完成情况报表", orgid, isShow); } byqdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='电容器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); Export11.ExportExceldrqEx(ex, byqdatalist, "电容器" + "预防性试验记录", orgid, isShow); //byqjhbdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyjl>("SelectPJ_yfsyjlList", " where type='电容器' and planExpTime like '%" + DateTime.Now.Year + "%' " + filter + " order by xh "); byqjhbdatalist = byqdatalist; Export11.ExportExceldrqjhbEx(ex, byqjhbdatalist, "电容器" + "预防性试验计划表", orgid, isShow); if (currRecord.Status != "申报") { Export11.ExportExceldrqssqkEx(ex, byqdatalist, "电容器" + "预防性试验实施情况记录", orgid, isShow); Export11.ExportExceldrqwcqkEx(ex, byqdatalist, "电容器" + "预防性试验完成情况报表", orgid, isShow); } IList<PJ_yfsyhcjl> hcdatalist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_yfsyhcjl>("SelectPJ_yfsyhcjlList", " where 1=1 " + filter + " order by xh "); Export11.ExportExcelhcEx(ex, hcdatalist, "设备维护实施记录", orgid, isShow); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } dsoFramerWordControl1.FileSave(); parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); }
private void btnOK_Click(object sender, EventArgs e) { if (rowData.BigData.Length == 0) { mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(rowData.ParentID); string fname = Application.StartupPath + "\\00记录模板\\23配电线路产权维护范围协议书.xls"; string bhname = org.OrgName.Replace("供电所", ""); DSOFramerControl dsoFramerControl1 = new DSOFramerControl(); dsoFramerControl1.FileOpen(fname); Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; //PJ_23 obj = (PJ_23)MainHelper.PlatformSqlMap.GetObject("SelectPJ_23List", "where ParentID='" + rowData.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "" + DateTime.Now.Year.ToString() + "%' order by xybh ASC"); //int icount = 1; //if (obj != null && obj.xybh !="") //{ // icount = Convert.ToInt32(obj.xybh.Split('-')[2])+1; //} //string strname = SelectorHelper.GetPysm(bhname, true); ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; ea.SetCellValue(rowData.xybh.ToUpper(), 4, 8); //strname = DateTime.Now.Year.ToString(); //ea.SetCellValue(strname, 4, 9); //strname = string.Format("{0:D3}", icount); //ea.SetCellValue(strname, 4, 10); ea.SetCellValue(rowData.linename, 10, 7); ea.SetCellValue(rowData.fzlinename, 10, 10); ea.SetCellValue("'" + rowData.gh, 10, 16); ea.SetCellValue(rowData.cqfw, 11, 4); ea.SetCellValue(rowData.cqdw, 13, 4); ea.SetCellValue(rowData.qdrq.Year.ToString(), 21, 7); ea.SetCellValue(rowData.qdrq.Month.ToString(), 21, 9); ea.SetCellValue(rowData.qdrq.Day.ToString(), 21, 11); dsoFramerControl1.FileSave(); rowData.BigData = dsoFramerControl1.FileData; dsoFramerControl1.FileClose(); dsoFramerControl1.Dispose(); dsoFramerControl1 = null; //rowData.xybh = SelectorHelper.GetPysm(bhname, true).ToUpper() + "-" + DateTime.Now.Year.ToString() + "-" + string.Format("{0:D3}", icount); } DSOFramerControl dsoFramerControl2 = new DSOFramerControl(); dsoFramerControl2.FileData = rowData.BigData; Microsoft.Office.Interop.Excel.Workbook wb2 = dsoFramerControl2.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ExcelAccess ea2 = new ExcelAccess(); ea2.MyWorkBook = wb2; ea2.MyExcel = wb2.Application; ea2.SetCellValue(comboBoxEdit1.Text, 11, 4); dsoFramerControl2.FileSave(); rowData.BigData = dsoFramerControl2.FileData; dsoFramerControl2.FileClose(); dsoFramerControl2.Dispose(); dsoFramerControl2 = null; }
private void btnOK_Click(object sender, EventArgs e) { //if (comboBoxEdit1.Text == "") //{ // MsgBox.ShowTipMessageBox("变动地点不能为空。"); // comboBoxEdit1.Focus(); // return; //} ////if (rowData.BigData == null) ////{ //// rowData.BigData = new byte[0]; ////} //this.DialogResult = DialogResult.OK; //this.Close(); IList<PJ_24> list = Client.ClientHelper.PlatformSqlMap.GetList<PJ_24>("where ParentID='" + rowData.ParentID + "'"); string bh = (list.Count + 1).ToString("000"); DSOFramerControl dsoFramerControl1 = new DSOFramerControl(); Microsoft.Office.Interop.Excel.Workbook wb; if (rowData.BigData == null || rowData.BigData.Length == 0) { string fname = Application.StartupPath + "\\00记录模板\\24设备变更通知书.xls"; dsoFramerControl1.FileOpen(fname); } else dsoFramerControl1.FileData = rowData.BigData; wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; DateTime dt = Convert.ToDateTime(dateEdit1.EditValue); ea.SetCellValue(dt.Year.ToString(), 4, 7); ea.SetCellValue(bh, 4, 10); ea.SetCellValue(dt.Year.ToString(), 9, 1); ea.SetCellValue(dt.Month.ToString(), 9, 3); ea.SetCellValue(dt.Day.ToString(), 9, 5); ea.SetCellValue(comboBoxEdit1.Text, 6, 7); ea.SetCellValue(memoEdit1.Text, 6, 8); ea.SetCellValue(memoEdit2.Text, 6, 11); dsoFramerControl1.FileSave(); rowData.BigData = dsoFramerControl1.FileData; dsoFramerControl1.FileClose(); dsoFramerControl1.Dispose(); dsoFramerControl1 = null; }
private void btView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridView1.FocusedRowHandle > -1) { PJ_ryda OBJECT = gridView1.GetRow(gridView1.FocusedRowHandle) as PJ_ryda; if (OBJECT.BigData != null) { if (OBJECT.BigData.Length != 0) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname = ""; saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; //WriteDoc(OBJECT.BigData, fname ); DSOFramerControl ds1 = new DSOFramerControl(); ds1.FileDataGzip = OBJECT.BigData; //ds1.FileSave(); //ds1.FileClose(); ds1.FileSave(fname, true); //ExcelAccess ex = new ExcelAccess(); //ex.Open(fname); //此处写填充内容代码 //ds1.FileSave(fname,true); ds1.FileClose(); ds1.Dispose(); //ex.ShowExcel(); if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } } } } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件路径"; if (dialog.ShowDialog() == DialogResult.OK) { ///循环判断当前目录下的文件和目录 DSOFramerControl ds1 = new DSOFramerControl(); string filepath = dialog.SelectedPath; GetFileList(ds1, filepath); //ds1.FileSave(); //ds1.FileClose(); ds1.Dispose(); if (parentObj!=null) RefreshData( "where OrgCode ='" + parentObj.OrgCode + "'"); } }
private void btExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode != null) { //Export17.ExportExcel(treeList1.FocusedNode); sdjls_sbpjb obj = MainHelper.PlatformSqlMap.GetOneByKey<sdjls_sbpjb>(treeList1.FocusedNode["ID"]); if (obj == null) return; string fname = ""; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; try { DSOFramerControl ds1 = new DSOFramerControl(); ds1.FileDataGzip = obj.BigData; ds1.FileSave(fname, true); ds1.FileClose(); if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } catch (Exception ex) { Console.WriteLine(ex.Message); MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); return; } } } }
public void ExportExcelSubmit(ref LP_Temple parentTemple, string orgid, string strProject, string strfenProject, bool isShow) { DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string fname = Application.StartupPath + "\\00记录模板\\出库单.xls"; dsoFramerWordControl1.FileOpen(fname); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent; ExcelAccess ex = new ExcelAccess(); Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ex.MyWorkBook = wb; ex.MyExcel = wb.Application; string strfirst = ""; string filter = ""; string filter2 = ""; string filter3 = ""; string filter4 = ""; if (strProject != "全部") filter2 = " where 1=1 and ssgc='" + strProject + "' and type = '撤旧材料出库单' "; else filter2 = " where 1=1 and type = '撤旧材料出库单' "; IList mclist = ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct ssgc from PJ_clcrkd " + filter2 + " order by ssgc"); foreach (string mc in mclist) { if (strfenProject == "全部") filter3 = " where 1=1 and type = '撤旧材料出库单' "; else filter3 = " where ssxm='" + strfenProject + "' and type = '撤旧材料出库单' "; IList xmlist = ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct ssxm from PJ_clcrkd " + filter3 + " order by ssxm"); foreach (string xm in xmlist) { filter4 = " where 1=1 and type = '撤旧材料出库单'" + " and ssgc='" + mc + "' " + " and ssxm='" + xm + "' "; //IList sjlist = ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct CONVERT(varchar(50) ,indate, 112 ) from PJ_clcrkd " + filter4 + " "); IList sjlist = ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct num from PJ_clcrkd " + filter4 + " "); foreach (string sj in sjlist) { filter = " where 1=1 and type = '撤旧材料出库单'" + " and ssgc='" + mc + "' " + " and ssxm='" + xm + "' and num= '" + sj + "' "; if (isWorkflowCall) { filter = filter + " and id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "') " + " or id in (select ModleRecordID from WF_ModleRecordWorkTaskIns where " + " RecordID='" + currRecord.ID + "') " ; } IList<PJ_clcrkd> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_clcrkd>( filter ); ExportExcel(ex, datalist); } } } //ex.ActiveSheet(1); //ex.DeleteWorkSheet(1); Excel.Worksheet sheet; for (int i = 1; i <= wb.Application.Sheets.Count; i++) { sheet = wb.Application.Sheets[i] as Excel.Worksheet; sheet.Cells.Clear(); sheet.Cells.ClearContents(); sheet.Cells.ClearOutline(); sheet.Visible = Excel.XlSheetVisibility.xlSheetHidden; dsoFramerWordControl1.FileSave(); break; } if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } dsoFramerWordControl1.FileSave(); parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileClose(); }
public void ExportExcelSubmit(ref LP_Temple parentTemple, string orgid, bool isShow) { DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string fname = Application.StartupPath + "\\00记录模板\\备品备件计划.xls"; dsoFramerWordControl1.FileOpen(fname); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent; ExcelAccess ex = new ExcelAccess(); Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ex.MyWorkBook = wb; ex.MyExcel = wb.Application; string filter = " where jhnf = '" + (DateTime.Now.Year + 1) + "'"; if (orgid != "") filter += " and OrgCode='" + orgid + "'"; if (isWorkflowCall) { filter = filter + " and (id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "') " + " or id in (select ModleRecordID from WF_ModleRecordWorkTaskIns where " + " RecordID='" + currRecord.ID + "')) " ; } IList<PJ_bpbjjhb> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_bpbjjhb>( filter ); ExportExcel(ex, datalist); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } dsoFramerWordControl1.FileSave(); parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileClose(); }
/// <summary> /// 文档格式预定义好的,只填写内容 /// </summary> /// <param name="obj"></param> public static void ExportExcel(PJ_20 obj) { ExcelAccess ex = new ExcelAccess(); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname =Application.StartupPath + "\\00记录模板\\20低压设备完好率及台区网络图"; //Ecommon.WriteDoc(obj.BigData,ref fname); saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; try { DSOFramerControl ds1 = new DSOFramerControl(); ds1.FileDataGzip = obj.BigData; ds1.FileSave(fname, true); ds1.FileClose(); if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } catch (Exception mex) { Console.WriteLine(mex.Message); MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); } } //此处写填充内容代码 }
public static void ExportExcelTQ(string tqCode) { ExcelAccess ex = new ExcelAccess(); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname =Application.StartupPath + "\\00记录模板\\20低压设备完好率及台区网络图"; //Ecommon.WriteDoc(obj.BigData,ref fname); saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { DSOFramerControl ds1 = new DSOFramerControl(); fname = saveFileDialog1.FileName; try {; IList<LP_Temple> templeList = null; LP_Temple parentTemple = MainHelper.PlatformSqlMap.GetOne<LP_Temple>("where ParentID not in (select LPID from LP_Temple where 1=1 and CtrlSize!='目录') and CellName like '%低压线路完好率及台区网络图%'"); if (parentTemple != null) { ds1.FileDataGzip = parentTemple.DocContent; Excel.Workbook wb = ds1.AxFramerControl.ActiveDocument as Excel.Workbook; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; templeList = MainHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList", "where ParentID ='" + parentTemple.LPID + "' order by SortID"); string valEX = @"[0-9]+(\.)?[0-9]+";//只允许整数或小数的正则表达式 int i=0; ArrayList al = new ArrayList(); Excel.Worksheet xx; for (i = 1; i <= wb.Application.Sheets.Count; i++) { xx = wb.Application.Sheets[i] as Excel.Worksheet; if (!al.Contains(xx.Name)) al.Add(xx.Name); } string activeSheetName = ""; foreach (LP_Temple lp in templeList) { IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList", " where UserControlId='" + parentTemple.LPID + "' and WorkflowId='" + tqCode + "' and WorkTaskInsId='20低压设备完好率及台区网络图'" + " and FieldId='"+lp.LPID+"' " +" order by YExcelPos"); object obj = null; double sum = 0; int idw = 1; if (lp.isExplorer == 1) { continue; } foreach (WF_TableFieldValue tfv in tfvli) { WF_TableFieldValue tfvtemp = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>( " where UserControlId='" + parentTemple.LPID+"'" + " and WorkflowId='" + tqCode + "'" + " and RecordId='" + tfv.RecordId + "'" + " and FieldName='类型'" +" and WorkTaskInsId='20低压设备完好率及台区网络图'" + " order by YExcelPos"); if (tfvtemp != null && tfvtemp.ControlValue == "新增") idw = 1; else if (tfvtemp != null && tfvtemp.ControlValue == "减少") idw = -1; else idw = 1; if (tfv.FieldName.IndexOf("时间") == -1&&lp.IsVisible==0) { valEX = "^[0-9]+(\\.)?[0-9]+"; if (tfv.ControlValue == "" || Regex.Match(tfv.ControlValue, valEX).Value!="") { if (tfv.ControlValue == "") sum += 0; else sum += idw * Convert.ToDouble(tfv.ControlValue); obj = sum; } else { obj = tfv.ControlValue; break; } } else { obj = tfv.ControlValue; break; } } if (!al.Contains(lp.KindTable)) { continue; } if (activeSheetName != lp.KindTable) { if (activeSheetName != "") { xx = wb.Application.Sheets[activeSheetName] as Excel.Worksheet; } xx = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet; activeSheetName = lp.KindTable; ea.ActiveSheet(xx.Index); } if (obj != null && tfvli.Count > 0 && tfvli[0].XExcelPos > 0 && tfvli[0].XExcelPos>0) ea.SetCellValue(obj.ToString(), tfvli[0].XExcelPos, tfvli[0].YExcelPos); } ds1.FileSave(fname, true); ds1.FileClose(); if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; } System.Diagnostics.Process.Start(fname); } catch (Exception mex) { Console.WriteLine(mex.Message); MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); } } //此处写填充内容代码 }
//public static int ExportToExcel(string title, string dw,PJ_17 pj17) //{ // string fname = Application.StartupPath + "\\00记录模板\\17线路条图.xls"; // string outfname = Application.StartupPath + "\\17线路条图.xls"; // float fxstart = 0,fystart = 0, fwidth = 0,fheight=0; // FpSpread fps = new FpSpread(); // FarPoint.Win.Spread.Model.CellRange cr = new FarPoint.Win.Spread.Model.CellRange(2, 2, 12, 12); // FarPoint.Win.LineBorder b = new FarPoint.Win.LineBorder(Color.Black, 1); // FarPoint.Win.LineBorder b2 = new FarPoint.Win.LineBorder(Color.Black, 2); // fps.OpenExcel(fname); // SheetView sv = fps.Sheets[0]; // PS_xl xl = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + pj17.LineCode + "'"); // if (xl == null) // { // MsgBox.ShowWarningMessageBox("数据出错,没找到线路"); // return -1; // } // int ColumnCount = sv.NonEmptyColumnCount; // int RowCount = sv.NonEmptyRowCount; // int ihang = 0,jlie=0; // int i = 0; // sv.ClearRange(0, 0, RowCount, ColumnCount, false); // //cr = new FarPoint.Win.Spread.Model.CellRange(4, 0, 23, 11); // //sv.SetOutlineBorder(cr, b); // sv.Cells[ihang, jlie].Text = title; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Regular | FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height =40; // sv.Cells[ihang, jlie].ColumnSpan = ColumnCount; // ihang = 1; // sv.Cells[ihang, jlie].Row.Height = 15; // #region 线路名称 // ihang = 2; // sv.Cells[ihang, jlie].Text = "线路名称:"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 1; // sv.Cells[ihang, jlie].Row.Height = 50; // string str =""; // string[] strname=new string[3]; // strname[0] = ""; // strname[1] = ""; // strname[2] = ""; // //if (xl.LineName.IndexOf("线") > 0) // //{ // // strname[0] = xl.LineName.Split('线')[0]; // // strname[1] = xl.LineName.Replace(strname[0]+"线",""); // //} // //else // // strname[1] = xl.LineName; // //if (strname[1].IndexOf("支") > 0) // //{ // // str = strname[1]; // // strname[1] = strname[1].Split('支')[0]; // // strname[2] = str.Replace(strname[1] + "支", ""); // //} // //else // //{ // // strname[2] = strname[1]; // // strname[1] = ""; // //} // //if (strname[2].IndexOf("分") < 0) // //{ // // if (strname[1] != "") // // strname[1] = strname[1] + "支" + strname[2]; // // else // // strname[0] = strname[0] + "线" + strname[2]; // // strname[2] = ""; // //} // //else // //{ // // strname[2] = strname[2].Split('分')[0]; // //} // if (xl.LineName.IndexOf("线") > 0) // { // strname[0] = xl.LineName.Split('线')[0]; // strname[1] = xl.LineName.Replace(strname[0] + "线", ""); // } // else // if (xl.LineName.IndexOf("支") > 0) // { // PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + xl.ParentID + "'"); // strname[0]=xltemp.LineName; // strname[1] = xl.LineName; // } // else if (xl.LineName.IndexOf("分") > 0) // { // PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + xl.ParentID + "'"); // if (xltemp != null) // { // strname[1] = xltemp.LineName; // xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + xltemp.ParentID + "'"); // if (xltemp != null) strname[0] = xltemp.LineName; // } // } // //if (strname[2].IndexOf("分") < 0) // //{ // // if (strname[1] != "") // // strname[1] = strname[1] + "支" + strname[2]; // // else // // strname[0] = strname[0] + "线" + strname[2]; // // strname[2] = ""; // //} // //else // //{ // // strname[2] = strname[2].Split('分')[0]; // //} // jlie = 1; // sv.Cells[ihang, jlie].Text = strname[0]; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // //sv.Cells[ihang, jlie].ColumnSpan = 3; // jlie ++; // sv.Cells[ihang, jlie].Text = "线"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Column.Width = 60f; // jlie++; // sv.Cells[ihang, jlie].Text = strname[1]; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // //sv.Cells[ihang, jlie].ColumnSpan = 3; // jlie++; // sv.Cells[ihang, jlie].Text = "支"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Column.Width = 30f; // jlie++; // sv.Cells[ihang, jlie].Text = strname[2]; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // //sv.Cells[ihang, jlie].ColumnSpan = 3; // jlie++; // sv.Cells[ihang, jlie].Text = "分"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Column.Width = 30f; // jlie ++; // sv.Cells[ihang, jlie].Text = "电压:"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // //sv.Cells[ihang, jlie].ColumnSpan = 3; // sv.Cells[ihang, jlie].Column.Width = 30f; // jlie++; // sv.Cells[ihang, jlie].Text = xl.LineVol; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Column.Width = 30f; // jlie ++; // sv.Cells[ihang, jlie].Text = "kV"; // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Column.Width = 30f; // #endregion // #region 表格外框 // ihang =4; // jlie = 0; // sv.Cells[ihang, jlie].Text = "平"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // sv.Cells[ihang, jlie].Row.Height = 80; // fheight += sv.Cells[ihang, jlie].Row.Height; // //fxstart += sv.Cells[ihang, jlie].Column.Width; // jlie = 2; // sv.Cells[ihang, jlie].Text = "A 相"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // ihang++; // jlie = 0; // sv.Cells[ihang, jlie].Text = "面"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // sv.Cells[ihang, jlie].Row.Height = 80; // fheight += sv.Cells[ihang, jlie].Row.Height; // jlie = 2; // sv.Cells[ihang, jlie].Text = "B 相"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // ihang++; // jlie = 0; // sv.Cells[ihang, jlie].Text = "图"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // sv.Cells[ihang, jlie].Row.Height = 80; // fheight += sv.Cells[ihang, jlie].Row.Height; // jlie = 2; // sv.Cells[ihang, jlie].Text = "C 相"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // cr = new FarPoint.Win.Spread.Model.CellRange(4, 0, 3, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // jlie =0; // sv.Cells[ihang, jlie].Text = "杆号"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "转角方向"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "杆高(m)"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "电杆种类及杆型"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "导线排列方式"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "导线规格"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "档距(m)"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "累计长度(m)"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "横担规格(mm)"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "拉线规格"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2); // sv.SetOutlineBorder(cr, b); // ihang++; // jlie = 0; // sv.Cells[ihang, jlie].Text = "绝缘子"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // sv.Cells[ihang, jlie].RowSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 2, 1); // sv.SetOutlineBorder(cr, b); // jlie = 1; // sv.Cells[ihang, jlie].Text = "规格"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // jlie =1; // sv.Cells[ihang, jlie].Text = "数量"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1,1); // sv.SetOutlineBorder(cr, b); // ihang++; // jlie = 0; // sv.Cells[ihang, jlie].Text = "变台"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].RowSpan = 4; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 4, 1); // sv.SetOutlineBorder(cr, b); // jlie = 1; // sv.Cells[ihang, jlie].Text = "型式"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "配变型号"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "台数"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "容量"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // jlie = 0; // sv.Cells[ihang, jlie].Text = "避雷器"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].RowSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 2,1); // sv.SetOutlineBorder(cr, b); // jlie = 1; // sv.Cells[ihang, jlie].Text = "规格"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "数量"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // jlie = 0; // sv.Cells[ihang, jlie].Text = "开关"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].RowSpan = 2; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 2, 1); // sv.SetOutlineBorder(cr, b); // jlie = 1; // sv.Cells[ihang, jlie].Text = "规格"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // ihang++; // sv.Cells[ihang, jlie].Text = "数量"; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].Row.Height = 40; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1); // sv.SetOutlineBorder(cr, b); // #endregion // #region 填充数据 // int istart = 1, iend = 1; // if (xl.LineGtend!="") // istart =Convert.ToInt32(xl.LineGtbegin); // else // istart = 0; // if (xl.LineGtbegin != "") // iend = Convert.ToInt32(xl.LineGtend); // else // iend = 0; // int liespan = 1,lieindex=0,itemp=0,spantemp=0 ; // ihang = 7; // IList<PS_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<PS_gt>( " Where LineCode='"+xl.LineCode +"'"); // iend = gtlis.Count; // int[] gtwidth = new int[iend]; // Hashtable hs = new Hashtable(); // for (i = 1; i <= iend; i++) // { // //杆塔数 // PS_gt gtobj = gtlis[i - 1]; // //if (gtobj == null) break ; // //绝缘子 // IList<PS_gtsb> jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='绝缘子' and gtID='" + gtobj.gtID + "'"); // //变台 // IList<PS_gtsb> btlist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='变台' and gtID='" + gtobj.gtID + "'"); // //避雷器 // IList<PS_gtsb> blqlist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='避雷器' and gtID='" + gtobj.gtID + "'"); // //开关 // IList<PS_gtsb> kglist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='开关' and gtID='" + gtobj.gtID + "'"); // //导线排列方式 // PS_gtsb dxobj = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbName='导线' and gtID='" + gtobj.gtID + "'"); // //横担拉线规格 // PS_gtsb hdobj = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbName='横担' and gtID='" + gtobj.gtID + "'"); // //拉线规格 // PS_gtsb lxobj = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbName='拉线' and gtID='" + gtobj.gtID + "'"); // liespan = 1; // if (jyuzlist.Count > liespan) liespan = jyuzlist.Count; // if (btlist.Count > liespan) liespan = btlist.Count; // if (blqlist.Count > liespan) liespan = blqlist.Count; // if (kglist.Count > liespan) liespan = kglist.Count; // //杆号 // ihang = 7; // jlie = lieindex+2; // sv.Cells[ihang, jlie].Text = i.ToString(); // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //转角方向 // ihang++; // sv.Cells[ihang, jlie].Text = ""; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //杆高(m) // ihang++; // if (gtobj != null) // { // sv.Cells[ihang, jlie].Text = gtobj.gtHeight.ToString(); // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // } // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //电杆种类及杆型 // ihang++; // if (gtobj != null) // { // if (gtobj.gtType != "" && gtobj.gtModle != "") // sv.Cells[ihang, jlie].Text = gtobj.gtType + "/" + gtobj.gtModle; // else if (gtobj.gtType == "" && gtobj.gtModle != "") // sv.Cells[ihang, jlie].Text = gtobj.gtModle; // else if (gtobj.gtType != "" && gtobj.gtModle == "") // sv.Cells[ihang, jlie].Text = gtobj.gtType; // if (sv.Cells[ihang, jlie].Text == "混凝土拔梢杆/直线杆") // { // sv.Cells[ihang, jlie].Text = "砼/直线杆"; // } // else // if (sv.Cells[ihang, jlie].Text.IndexOf( "混凝土")>-1) // { // sv.Cells[ihang, jlie].Text = "砼"; // } // } // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //导线排列方式 // ihang++; // if (dxobj != null) // { // sv.Cells[ihang, jlie].Text = dxobj.C1; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // } // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //导线规格 // ihang++; // if (dxobj != null) // { // sv.Cells[ihang, jlie].Text = dxobj.sbModle; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // } // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //档距(m) // ihang++; // if (gtobj != null) // { // sv.Cells[ihang, jlie].Text = gtobj.gtSpan.ToString(); // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // } // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //累计长度(m) // ihang++; // //if (xl != null) // //{ // // sv.Cells[ihang, jlie].Text = xl.TotalLength.ToString(); // // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // //} // //sv.Cells[ihang, jlie].ColumnSpan = liespan; // //cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // //sv.SetOutlineBorder(cr, b); // //横担 // ihang++; // if (hdobj != null) // { // sv.Cells[ihang, jlie].Text = hdobj.sbModle; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // } // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //拉线规格 // ihang++; // if (lxobj != null) // { // sv.Cells[ihang, jlie].Text = lxobj.sbModle; // sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center; // } // sv.Cells[ihang, jlie].ColumnSpan = liespan; // cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // //绝缘子 // ihang++; // spantemp = 0; // for (itemp = 0; itemp < jyuzlist.Count; itemp++) // { // sv.Cells[ihang, jlie + itemp].Text = jyuzlist[itemp ].sbModle; // sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie + itemp].ColumnSpan = 1; // sv.Cells[ihang + 1, jlie + itemp].Text = jyuzlist[itemp].sbNumber.ToString(); // sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang, jlie + itemp].ColumnSpan; // ////自动行宽30f; // //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[jlie + itemp].GetPreferredWidth(); // fps.ActiveSheet.Columns[jlie + itemp].Width = 30f; // } // for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++) // { // cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // } // if (!hs.ContainsKey(gtobj.gtID)) // hs.Add(gtobj.gtID, 0); // else // hs[gtobj.gtID] = 0; // //变台 // ihang += sv.Cells[ihang, 0].RowSpan; // for (itemp = 0; itemp < btlist.Count; itemp++) // { // sv.Cells[ihang, jlie + itemp].Text = btlist[itemp].sbType ; // sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie + itemp].ColumnSpan = 1; // if (btlist[itemp].sbType == "H台") // { // sv.Cells[4, jlie + itemp].Text = gtobj.gtCode; // if (!hs.ContainsKey(gtobj.gtID)) // hs.Add(gtobj.gtID, 1); // else // hs[gtobj.gtID] = 1; // } // sv.Cells[ihang + 1, jlie + itemp].Text = btlist[itemp].sbModle; // sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang+1, jlie + itemp].ColumnSpan; // sv.Cells[ihang + 2, jlie + itemp].Text = btlist[itemp].sbNumber.ToString () ; // sv.Cells[ihang + 2, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang + 2, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang + 2, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang + 2, jlie + itemp].ColumnSpan = sv.Cells[ihang+2, jlie + itemp].ColumnSpan; // sv.Cells[ihang + 3, jlie + itemp].Text = btlist[itemp].C1 ; // sv.Cells[ihang + 3, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang + 3, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang + 3, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang + 3, jlie + itemp].ColumnSpan = sv.Cells[ihang+3, jlie + itemp].ColumnSpan; // ////自动行宽 // //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[jlie + itemp].GetPreferredWidth(); // fps.ActiveSheet.Columns[jlie + itemp].Width = 30f; // } // for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++) // { // cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // } // //避雷器 // ihang += sv.Cells[ihang, 0].RowSpan; // for (itemp = 0; itemp < blqlist.Count; itemp++) // { // sv.Cells[ihang, jlie + itemp].Text = blqlist[itemp].sbModle; // sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie + itemp].ColumnSpan = 1; // sv.Cells[ihang + 1, jlie + itemp].Text = blqlist[itemp].sbNumber.ToString(); // sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // //sv.Cells[ihang + 1, jlie + itemp].Column.Width = 80; // sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang, jlie + itemp].ColumnSpan; // ////自动行宽 // //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[i].GetPreferredWidth(); // fps.ActiveSheet.Columns[jlie + itemp].Width = 30f; // } // for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++) // { // cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // } // //开关 // ihang += sv.Cells[ihang, 0].RowSpan; // for (itemp = 0; itemp < kglist.Count; itemp++) // { // sv.Cells[ihang, jlie + itemp].Text = kglist[itemp].sbModle; // sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[ihang, jlie + itemp].ColumnSpan = 1; // sv.Cells[ihang + 1, jlie + itemp].Text = kglist[itemp].sbNumber.ToString(); // sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center; // //sv.Cells[ihang + 1, jlie + itemp].Column.Width = 80; // sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang+1, jlie + itemp].ColumnSpan; // ////自动行宽 // //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[i].GetPreferredWidth(); // fps.ActiveSheet.Columns[jlie + itemp].Width = 30f; // } // for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++) // { // cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan); // sv.SetOutlineBorder(cr, b); // } // ////自动行宽 // //fps.ActiveSheet.Columns[jlie].Width = fps.ActiveSheet.Columns[jlie].GetPreferredWidth(); // fps.ActiveSheet.Columns[jlie + itemp].Width = 30f; // lieindex += liespan; // fwidth += fps.ActiveSheet.Columns[jlie].Width; // //for (itemp = 0; itemp < sv.Cells[8, jlie].ColumnSpan; itemp++) // // gtwidth[i - 1] += sv.Cells[ihang, jlie + itemp].Column.Width; // gtwidth[i - 1] = liespan; // } // cr = new FarPoint.Win.Spread.Model.CellRange(4, 2, 3, lieindex); // sv.SetOutlineBorder(cr, b); // //累计长度(m) // sv.Cells[14, 2].Text = xl.TotalLength.ToString(); // sv.Cells[14, 2].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // sv.Cells[14, 2].HorizontalAlignment = CellHorizontalAlignment.Center; // sv.Cells[14, 2].VerticalAlignment = CellVerticalAlignment.Center; // sv.Cells[14, 2].ColumnSpan = lieindex; // cr = new FarPoint.Win.Spread.Model.CellRange(14, 2, 1, lieindex); // sv.SetOutlineBorder(cr, b); // ihang += sv.Cells[ihang, 0].RowSpan; // fystart = 0; // for (itemp = 0; itemp <=4; itemp++) // { // if(itemp <4) // fystart += sv.Cells[itemp, 0].Row.Height; // else // fystart += sv.Cells[itemp, 0].Row.Height/2; // } // #endregion // ColumnCount = sv.NonEmptyColumnCount; // RowCount = sv.NonEmptyRowCount; // sv.Cells[0, 0].ColumnSpan = ColumnCount; // fps.SaveExcel(outfname); // #region 画图形 // DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); // dsoFramerWordControl1.FileOpen(outfname); // Microsoft.Office.Interop.Excel.Workbook wb; // Microsoft.Office.Interop.Excel.Worksheet xx; // try { // wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; // xx = wb.Application.Sheets[1] as Microsoft.Office.Interop.Excel.Worksheet; // } catch (Exception err) { // dsoFramerWordControl1.FileClose(); // throw new Exception("excel的打开方式不对,有可能装有wps", err); // } // Excel.Range range; // if (lieindex < 1) // range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount , ColumnCount]); // else // range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, lieindex + 2]); // range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous; // range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Excel.XlBorderWeight.xlThick; // range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight ].LineStyle = Excel.XlLineStyle.xlContinuous; // range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].Weight = Excel.XlBorderWeight.xlThick; // range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom ].LineStyle = Excel.XlLineStyle.xlContinuous; // range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Excel.XlBorderWeight.xlThick; // float gwidth = 13.50F, gheifht = 15.75F; // Microsoft.Office.Interop.Excel.Shape activShape,oldShape=null; // int icolor = (int)(((uint)Color.White.B << 16) | (ushort)(((ushort)Color.White.G << 8) | Color.White.R)); // i =3; // range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6,2]); // fxstart = (float)Convert.ToDouble(range.Cells.Width); // for (itemp = 0; itemp < gtlis.Count; itemp++) // { // range = (Excel.Range)xx.get_Range(xx.Cells[8, i], xx.Cells[8, i + gtwidth[itemp] - 1]); // float width = (float)Convert.ToDouble(range.Cells.Width); // if (hs[gtlis[itemp].gtID].ToString() == "1") // { // activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart - gwidth + width / 2, fystart, gwidth, gheifht); // //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht); // activShape.Fill.ForeColor.RGB = icolor; // if (itemp > 0) // { // //Texture Image Recognition Algorithm Based on Steerable Pyramid Transform // xx.Shapes.AddLine(oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, activShape.Left, activShape.Top + activShape.Height / 2); // } // activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, activShape.Left + activShape.Width, fystart, gwidth, gheifht); // activShape.Fill.ForeColor.RGB = icolor; // } // else // { // activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht); // //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht); // activShape.Fill.ForeColor.RGB = icolor; // if (itemp > 0) // { // //Texture Image Recognition Algorithm Based on Steerable Pyramid Transform // xx.Shapes.AddLine(oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, activShape.Left, activShape.Top + activShape.Height / 2); // } // } // //fxstart += gtwidth[itemp]; // fxstart += width; // i += gtwidth[itemp]; // oldShape = activShape; // } // dsoFramerWordControl1.FileSave(); // pj17.BigData = dsoFramerWordControl1.FileDataGzip; // dsoFramerWordControl1.FileClose(); // dsoFramerWordControl1.Dispose(); // #endregion // //System.Diagnostics.Process.Start(outfname); // return 1; //} public static int ExportToExcel(string title, string dw, PJ_17 pj17) { string fname = Application.StartupPath + "\\00记录模板\\17线路条图2.xls"; float fxstart = 0, fystart = 0, fwidth = 0, fheight = 0; DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string outfname = Path.GetTempFileName() + ".xls"; File.Copy(fname, outfname); dsoFramerWordControl1.FileOpen(outfname); Microsoft.Office.Interop.Excel.Worksheet xx; Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; ExcelAccess ex = new ExcelAccess(); ex.MyWorkBook = wb; ex.MyExcel = wb.Application; PS_xl xl = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + pj17.LineCode + "'"); try { if (xl == null) { MsgBox.ShowWarningMessageBox("数据出错,没找到线路"); return -1; } string strLinexh = xl.WireType;//导线型号 PS_gt gtformer = null; IList<PS_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<PS_gt>(" Where LineCode='" + xl.LineCode + "' order by gtcode"); gtformer = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gt>(" Where gtID='" + xl.ParentGT + "'"); gtlis.Insert(0, gtformer); //计算页码 int pagecount = 1, jmax = 15, m = 0, j = 0; pagecount = gtlis.Count / 15 + 1; int ihang = 8, jlie = 2; int i = 0; //复制空模板 for (m = 1; m < pagecount; m++) { ex.CopySheet(1, m); ex.ReNameWorkSheet(m + 1, "Sheet" + (m + 1)); } string[] strname = new string[3]; strname[0] = ""; strname[1] = ""; strname[2] = ""; if (xl.LineType == "1") { strname[0] = xl.LineName.Split('线')[0] + "线"; strname[1] = xl.LineName.Replace(strname[0], ""); } else if (xl.LineType == "2") { PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineID='" + xl.ParentID + "'"); if (xltemp != null) strname[0] = xltemp.LineName; strname[1] = xl.LineName.Replace(xltemp.LineName, ""); } else if (xl.LineType == "3") { strname[2] = xl.LineName; PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineID='" + xl.ParentID + "'"); if (xltemp != null) { strname[1] = xltemp.LineName; xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineID='" + xltemp.ParentID + "'"); if (xltemp != null) strname[0] = xltemp.LineName; } strname[2].Replace(strname[1], ""); strname[1].Replace(strname[0], ""); } //填写公共项 for (m = 1; m <= pagecount; m++) { ex.ActiveSheet("Sheet" + m); ex.SetCellValue(strname[0], 3, 2); ex.SetCellValue(strname[1], 3, 5); ex.SetCellValue(strname[2], 3, 11); ex.SetCellValue(xl.LineVol.ToString(), 3, 20); } ihang = 8; jlie = 3; int hdRowCount = 1; int jyzRowCount = 1; int dxRowCount = 1; int btRowCount = 1; int blqRowCount = 1; int kgRowCount = 1; int lxRowCount = 1; int jstart = 3; double dc = 0; string strfx = ""; Excel.Range range; for (i = 1; i < gtlis.Count; i++) { if ((i + 0.0) % (jmax) == 1) { jlie = 3; ihang = 8; hdRowCount = 1; jyzRowCount = 1; dxRowCount = 1; btRowCount = 1; blqRowCount = 1; kgRowCount = 1; lxRowCount = 1; } if (Math.Ceiling((i + 0.0) / (jmax)) > 1) { ex.ActiveSheet("Sheet" + Math.Ceiling((i + 0.0) / (jmax))); xx = wb.Application.Sheets["Sheet" + Math.Ceiling((i + 0.0) / (jmax))] as Microsoft.Office.Interop.Excel.Worksheet; } else { ex.ActiveSheet("Sheet1"); xx = wb.Application.Sheets["Sheet1"] as Microsoft.Office.Interop.Excel.Worksheet; } //ex.SetCellValue(i.ToString(), ihang, jlie); ////杆塔数 PS_gt gtobj = gtlis[i]; //if (gtobj == null) //{ // if ((i + 0.0) % (jmax) == 0&&i>1) // { // //累计长度 // double sum = 0; // for (int item = i; item < i + 15 && item < gtlis.Count; item++) // { // PS_gt gttemp = gtlis[item]; // if (gttemp != null) // { // sum += Convert.ToDouble(gttemp.gtSpan); // } // } // ex.SetCellValue(sum.ToString(), ihang, 2); // } // jlie += 2; // continue; //} //绝缘子 string strSQL = "select distinct sbModle from PS_gtsb Where gtID='" + gtobj.gtID + "' "; if (xl.LineVol != "" && Convert.ToDouble(xl.LineVol) >= 10) { strSQL += " and (sbName like '高压%立瓶%' or sbName like '高压%悬垂%' or sbName like '高压%茶台%' )"; } else if (xl.LineVol != "" && 0.4 >= Convert.ToDouble(xl.LineVol)) { strSQL += " and (sbName like '低压%立瓶%' or sbName like '低压%茶台%' )"; } IList jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL); //变台 //IList btlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb Where sbName like '%变压器%' and gtID='" + gtobj.gtID + "'"); IList btlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct bttype from PS_tq Where gtID='" + gtobj.gtID + "'"); //避雷器 IList blqlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb Where sbName='避雷器' and gtID='" + gtobj.gtID + "'"); //开关 IList kglist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct kgModle from PS_kg Where gtID='" + gtobj.gtID + "'"); //导线型号 IList dxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbModle from PS_gtsb Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'"); //导线排列方式 IList dxpllist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct C1 from PS_gtsb Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'"); //横担规格 IList hdobj = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb Where sbName like '%横担%' and gtID='" + gtobj.gtID + "'"); //拉线规格 IList lxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb Where sbName like '%拉线%' and gtID='" + gtobj.gtID + "'"); IList ilisttemp = null; ihang = 8; ////杆号 ex.SetCellValue((i).ToString(), ihang, jlie); ihang++; //转角方向 if (gtobj.gtModle.IndexOf("转角") > -1) { if (i != 1 && i < gtlis.Count - 1) { decimal[,] a1 = new decimal[1, 2]; decimal[,] a2 = new decimal[1, 2]; a1[0, 0] = gtlis[i].gtLat - gtlis[i - 1].gtLat; a1[0, 1] = gtlis[i].gtLon - gtlis[i - 1].gtLon; a2[0, 0] = gtlis[i + 1].gtLat - gtlis[i].gtLat; a2[0, 1] = gtlis[i + 1].gtLon - gtlis[i].gtLon; decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1]; double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble( a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1]))); dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0); if (gtlis[i].gtLon > gtlis[i - 1].gtLon) { strfx = "右转"; } else { strfx = "左转"; } if (dc.ToString() != "NaN" && dc.ToString() != "非数字") ex.SetCellValue(strfx + dc + "度", ihang, jlie); else { } } } ihang++; //杆高(m) if (gtobj != null) { ex.SetCellValue(gtobj.gtHeight.ToString(), ihang, jlie); } ihang++; //电杆种类/杆型 if (gtobj != null) { string strtype = "", strzj = ""; if (gtobj.gtType.IndexOf("混凝土拔梢杆") > -1) { strtype = "砼"; } if (gtobj.gtModle.IndexOf("直线杆") > -1) { strzj = "直"; } else if (gtobj.gtModle.IndexOf("分支杆") > -1) { strzj = "分"; } else if (gtobj.gtModle.IndexOf("转角杆") > -1) { strzj = "转"; } else if (gtobj.gtModle.IndexOf("耐张杆") > -1) { strzj = "耐"; } else if (gtobj.gtModle.IndexOf("终端杆") > -1) { strzj = "终"; } if (strtype != "" && strzj != "") { ex.SetCellValue(strtype + "/" + strzj, ihang, jlie); } else { ex.SetCellValue(gtobj.gtType + "/" + gtobj.gtModle, ihang, jlie); } } ihang++; //导线排列方式 if (hdobj.Count > 0 && hdobj[0].ToString().Contains("三角")) { ex.SetCellValue("三角排列", ihang, jlie); } else { ex.SetCellValue("水平排列", ihang, jlie); } /* if (((i + 0.0) % (jmax) == 0 && i > 1) || i == gtlis.Count) { //合并同类项 string stplrname = ""; int ista = i, item = i, jlietemp = jlie; for (item = i; item > 1; item--) { PS_gt gttemp = gtlis[item - 1]; PS_gt gttemp2 = gtlis[item - 2]; IList dxpllist2 = null; IList dxpllist3 = null; string str1 = "", str2 = ""; if (gttemp != null) { dxpllist2 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbName from PS_gtsb Where sbName like '%横担%' and gtID='" + gttemp.gtID + "'"); if (dxpllist2.Count > 0) str1 = dxpllist2[0].ToString(); } if (gttemp2 != null) { dxpllist3 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbName from PS_gtsb Where sbName like '%横担%' and gtID='" + gttemp2.gtID + "'"); if (dxpllist3.Count > 0) str2 = dxpllist3[0].ToString(); } if (gttemp2 == null || str2 == str1) { if (jlietemp > 4) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang, jlietemp], xx.Cells[ihang, jlietemp - 2]); range.Merge(Type.Missing); if ((item % jmax == 2 && ista != item) || jlietemp == 5) { if (str1 != "" && str1.Contains("三角")) { ex.SetCellValue("角排列", ihang, jlietemp - 2); } else { ex.SetCellValue("水平排列", ihang, jlietemp - 2); } } } } else { if (str1 != "" && str1.Contains("三角")) { ex.SetCellValue("角排列", ihang, jlietemp); } else { ex.SetCellValue("水平排列", ihang, jlietemp); } } jlietemp = jlietemp - 2; if (item % jmax == 2 && ista != item) { break; } } } else { if (gtlis.Count>0) { string stplrname = ""; int ista = i, item = i, jlietemp = jlie; for (item = i; item > 1; item--) { PS_gt gttemp = gtlis[item - 1]; PS_gt gttemp2 = gtlis[item - 2]; IList dxpllist2 = null; IList dxpllist3 = null; string str1 = "", str2 = ""; if (gttemp != null) { dxpllist2 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbName from PS_gtsb Where sbName like '%横担%' and gtID='" + gttemp.gtID + "'"); if (dxpllist2.Count > 0) str1 = dxpllist2[0].ToString(); } if (gttemp2 != null) { dxpllist3 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbName from PS_gtsb Where sbName like '%横担%' and gtID='" + gttemp2.gtID + "'"); if (dxpllist3.Count > 0) str2 = dxpllist3[0].ToString(); } if (gttemp2 == null || str2 == str1) { if (jlietemp > 4) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang, jlietemp], xx.Cells[ihang, jlietemp - 2]); range.Merge(Type.Missing); if ((item % jmax == 2 && ista != item) || jlietemp == 5) { if (str1 != "" && str1.Contains("三角")) { ex.SetCellValue("角排列", ihang, jlietemp - 2); } else { ex.SetCellValue("水平排列", ihang, jlietemp - 2); } } } } else { if (str1 != "" && str1.Contains("三角")) { ex.SetCellValue("角排列", ihang, jlietemp); } else { ex.SetCellValue("水平排列", ihang, jlietemp); } } jlietemp = jlietemp - 2; if (item % jmax == 2 && ista != item) { break; } } } } */ ihang++; //导线型号规格(mm2) if (dxlist != null && dxlist.Count > 0) { if (dxlist.Count > dxRowCount) { for (j = dxRowCount; j < dxlist.Count; j++) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + dxRowCount, "A"], xx.Cells[ihang + dxRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); } for (int jtem = 1; jtem < dxlist.Count; jtem++) { for (int item = 0; item < 29; item += 2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]); range.Merge(Type.Missing); } } dxRowCount = dxlist.Count; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + dxRowCount - 1, 1]); range.Merge(Type.Missing); } if (dxlist.Count > 0) { for (j = 0; j < dxlist.Count; j++) ex.SetCellValue(dxlist[j].ToString(), ihang + j, jlie); } } else { ex.SetCellValue(strLinexh, ihang, jlie); } ihang += dxRowCount; if (i == 15) { int nn = 0; } //档 距(m) if (gtobj != null && gtobj.gtSpan > 0) { if (jlie > 3) ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie - 1); else ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie); } ihang++; //累计长度 if (((i + 0.0) % (jmax) == 0 && i > 1) || i == gtlis.Count - 1) { //累计长度 double sum = 0; int ista = i, item = i; for (item = i; item > 0; item--) { PS_gt gttemp = gtlis[item]; if (gttemp != null) { sum += Convert.ToDouble(gttemp.gtSpan); } if (i < gtlis.Count - 1) { if (item % jmax == 1 && ista != item) { break; } } else { if (item % jmax == 1) { break; } } } sum = 0; for (int m1 = 0; m1 < gtlis.Count; m1++) { PS_gt gttemp = gtlis[m1]; if (gttemp != null) { sum += Convert.ToDouble(gttemp.gtSpan); } } ex.SetCellValue(sum.ToString(), ihang, jstart); float gwidth = 13.50F, gheifht = 13.50F; //float gwidth = 10F, gheifht = 10F; Microsoft.Office.Interop.Excel.Shape activShape, oldShape = null, kywShape = null; int icolor = (int)(((uint)Color.White.B << 16) | (ushort)(((ushort)Color.White.G << 8) | Color.White.R)); range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]); fxstart = (float)Convert.ToDouble(range.Cells.Width); range = (Excel.Range)xx.get_Range(xx.Cells[6, 2], xx.Cells[6, 2]); fxstart += (float)Convert.ToDouble(range.Cells.Width); range = (Excel.Range)xx.get_Range(xx.Cells[1, 1], xx.Cells[5, 1]); fystart = (float)Convert.ToDouble(range.Cells.Height); range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]); fystart = fystart + (float)(Convert.ToDouble(range.Cells.Height) / 2); activShape = null; for (int itemp = 0; itemp <= ista - item; itemp++) { range = (Excel.Range)xx.get_Range(xx.Cells[6, itemp * 2 + jstart], xx.Cells[6, itemp * 2 + jstart + 1]); float width = (float)Convert.ToDouble(range.Cells.Width); PS_xl xl2 = Client.ClientHelper.PlatformSqlMap.GetOne<PS_xl>("where ParentGT='" + gtlis[item + itemp].gtID + "'"); if (xl2 == null) { if (gtlis[item + itemp].gtModle.IndexOf("转角") == -1) { activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht); } else { PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '直角'"); if (tb2 != null) { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb2.picImage); bw.Flush(); bw.Close(); fs.Close(); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); decimal[,] a1 = new decimal[1, 2]; decimal[,] a2 = new decimal[1, 2]; if (item + itemp < gtlis.Count) { a1[0, 0] = gtlis[item + itemp].gtLat - gtlis[item + itemp - 1].gtLat; a1[0, 1] = gtlis[item + itemp].gtLon - gtlis[item + itemp - 1].gtLon; a2[0, 0] = gtlis[item + itemp + 1].gtLat - gtlis[item + itemp].gtLat; a2[0, 1] = gtlis[item + itemp + 1].gtLon - gtlis[item + itemp].gtLon; } decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1]; double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble( a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1]))); dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0); if (gtlis[item + itemp].gtLon > gtlis[item + itemp - 1].gtLon) { strfx = "右转"; } else { strfx = "左转"; } int btw = (int)(bt.Width / 1.33f); int bth = (int)(bt.Height / 1.33f); if (btw < width / 2) { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth); if (strfx == "左转") { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 - Convert.ToDouble(dc)); } else { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 + Convert.ToDouble(dc)); } } else { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bt.Height / 2, bt.Width, bt.Height); if (strfx == "左转") { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 - Convert.ToDouble(dc)); } else { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 + Convert.ToDouble(dc)); } } } } } else { ex.SetCellValue(xl2.LineName, 5, itemp * 2 + 4);//分支线路 PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '分支'"); if (tb2 != null) { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb2.picImage); bw.Flush(); bw.Close(); fs.Close(); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); int btw = (int)(bt.Width / 1.33f); int bth = (int)(bt.Height / 1.33f); if (btw < width / 2) { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth); } else { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bth / 2, btw, bth); } } else { activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht); } } //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht); activShape.Fill.ForeColor.RGB = icolor; if (itemp > 0) { IList<PJ_05jcky> kyxli = MainHelper.PlatformSqlMap.GetList<PJ_05jcky>(" where gtID='" + gtlis[item + itemp].gtID + "'"); if (kyxli.Count == 0) { //Texture Image Recognition Algorithm Based on Steerable Pyramid Transform //if (Export17.ExistsRegedit() == 1) {//vs2003 // xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight, // oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, // //activShape.Left , oldShape.Top + oldShape.Height / 2); // activShape.Left - (oldShape.Left + oldShape.Width), 0); //} else { xx.Shapes.AddLine( oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, activShape.Left, activShape.Top + activShape.Height / 2); } } else { PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + kyxli[0].kymc + "'"); if (tb != null) { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb.picImage); bw.Flush(); bw.Close(); fs.Close(); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); int btw = (int)(bt.Width / 1.33f); int bth = (int)(bt.Height / 1.33f); if (btw < width / 2) { kywShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, oldShape.Left + oldShape.Width + width / 2 - btw / 2, oldShape.Top + oldShape.Height / 2 - bth / 2, btw, bth); // xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight, //oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, //kywShape.Left, oldShape.Top + oldShape.Height / 2); xx.Shapes.AddLine( oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, kywShape.Left, oldShape.Top + oldShape.Height / 2); // xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight, //kywShape.Left + (float)(kywShape.Width - 2), kywShape.Top + kywShape.Height / 2, //activShape.Left + 2, kywShape.Top + kywShape.Height / 2); xx.Shapes.AddLine( kywShape.Left + (float)(kywShape.Width - 2), kywShape.Top + kywShape.Height / 2, activShape.Left + 2, kywShape.Top + kywShape.Height / 2); } else { // kywShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, oldShape.Left + oldShape.Width + width / 5, oldShape.Top + oldShape.Height / 2 - bth / 2, btw, bth); // xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight, // oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, // kywShape.Left, oldShape.Top + oldShape.Height / 2); // xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight, //kywShape.Left + (float)(kywShape.Width - 1), kywShape.Top + kywShape.Height / 2, //activShape.Left + 1, kywShape.Top + kywShape.Height / 2); xx.Shapes.AddLine( oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, kywShape.Left, oldShape.Top + oldShape.Height / 2); xx.Shapes.AddLine( kywShape.Left + (float)(kywShape.Width - 1), kywShape.Top + kywShape.Height / 2, activShape.Left + 1, kywShape.Top + kywShape.Height / 2); } //Image im = Bitmap.FromFile(tempfile); //Bitmap bt = new Bitmap(im); //DataObject dataObject = new DataObject(); //dataObject.SetData(DataFormats.Bitmap, bt); //Clipboard.SetDataObject(dataObject, true); } } } //fxstart += gtwidth[itemp]; fxstart += width; oldShape = activShape; } } ihang++; //横担 if (hdobj != null && hdobj.Count > 0) { if (hdobj.Count > hdRowCount) { for (j = hdRowCount; j < hdobj.Count; j++) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + hdRowCount, "A"], xx.Cells[ihang + hdRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); for (int item = 0; item < 29; item += 2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + hdRowCount, jstart + item], xx.Cells[ihang + hdRowCount, jstart + 1 + item]); range.Merge(Type.Missing); } } hdRowCount = hdobj.Count; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + hdRowCount - 1, 1]); range.Merge(Type.Missing); } for (j = 0; j < hdobj.Count; j++) { ex.SetCellValue(hdobj[j].ToString(), ihang + j, jlie); //if (j + 1 < hdobj.Count) //{ // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + 1, 1], xx.Cells[ihang + 1, 1]); // range.Insert(Excel.XlInsertShiftDirection.xlShiftDown, Type.Missing); // ihang++; //} } } ihang += hdRowCount; //拉线规格/条数 if (lxlist != null && lxlist.Count > 0) { if (lxlist.Count > lxRowCount) { for (j = lxRowCount; j < lxlist.Count; j++) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + lxRowCount, "A"], xx.Cells[ihang + lxRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); //for (int item = 0; item < 29; item += 2) //{ // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j + 1, jstart + item], xx.Cells[ihang + j + 1, jstart + 1 + item]); // range.Merge(Type.Missing); //} } for (int jtem = lxRowCount; jtem < lxlist.Count; jtem++) { for (int item = 0; item < 29; item += 2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + item + 1]); range.Merge(Type.Missing); } } lxRowCount = lxlist.Count; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + lxRowCount - 1, 1]); range.Merge(Type.Missing); } for (j = 0; j < lxlist.Count; j++) { int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select sum(sbNumber) from PS_gtsb where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'")); //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); ex.SetCellValue(lxlist[j].ToString()/* + "/" + icount*/, ihang + j, jlie); } } ihang += lxRowCount; //绝缘子型号/数量 if (jyuzlist != null) { if (jyuzlist.Count > jyzRowCount) { for (j = jyzRowCount + 1; j < jyuzlist.Count; j = j + 2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jyzRowCount, "A"], xx.Cells[ihang + jyzRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]); range.Merge(Type.Missing); } //for (int jtem = 0; jtem < jyuzlist.Count; jtem++) { // for (int item = 0; item < 29; item += 2) { // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]); // range.Merge(Type.Missing); // } //} jyzRowCount = jyuzlist.Count / 2 + jyuzlist.Count % 2 == 0 ? 0 : 1; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + jyzRowCount - 1, 1]); range.Merge(Type.Missing); } for (j = 0; j < jyuzlist.Count; j++) { int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select sum(sbNumber) from PS_gtsb where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'")); //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); ex.SetCellValue(jyuzlist[j].ToString() /*+ "/" + icount*/, ihang + j / 2, jlie + j % 2); ex.SetCellValue(icount.ToString(), ihang + j / 2 + 1, jlie + j % 2); } } ihang += jyzRowCount * 2; //变台型式 if (btlist != null) { if (btlist.Count > 0) { //ilisttemp = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbCode from PS_gtsb Where sbModle = '" + btlist[0].ToString() + "' and gtID='" + gtobj.gtID + "'"); ilisttemp = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct byqModle from PS_tqbyq Where tqID in ( select tqID from PS_tq where gtID='" + gtobj.gtID + "')"); //if (ilisttemp.Count > btRowCount) { // for (j = btRowCount; j < ilisttemp.Count; j++) { // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + btRowCount + 1, "A"], xx.Cells[ihang + btRowCount + 1, "A"]); // range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j + 1, 2]); // range.Merge(Type.Missing); // } // for (int jtem = 1; jtem < ilisttemp.Count; jtem++) { // for (int item = 0; item < 29; item += 2) { // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem + 3, jstart + item], xx.Cells[ihang + jtem + 3, jstart + item + 1]); // range.Merge(Type.Missing); // } // } // btRowCount = ilisttemp.Count; // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + 1, 1], xx.Cells[ihang + btRowCount + 1 - 1, 1]); // range.Merge(Type.Missing); //} //if (btlist.Count == 1) ex.SetCellValue(btlist[0].ToString(), ihang, jlie); //else //{ // j = j; //} int byqrl = 0; int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select count(*) from PS_tqbyq where tqID in ( select tqID from PS_tq where gtID='" + gtobj.gtID + "')")); for (j = 0; j < Math.Min(ilisttemp.Count, 2); j++) {//只能显示两个 //int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select sum(sbNumber) from PS_gtsb where sbCode='" + ilisttemp[0].ToString() + "' and sbModle = '" + btlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'")); ////int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbCode='" + ilisttemp[0].ToString() + "' and sbModle = '" + btlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); //PS_gtsb gtsbtemp = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbCode='" + ilisttemp[0].ToString() + "' and sbModle = '" + btlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); PS_tqbyq gtsbtemp = Client.ClientHelper.PlatformSqlMap.GetOne<PS_tqbyq>(" Where byqModle='" + ilisttemp[j].ToString() + "' and tqID in ( select tqID from PS_tq where gtID='" + gtobj.gtID + "')"); if (gtsbtemp != null) { //PS_sbcs sbcstemp = Client.ClientHelper.PlatformSqlMap.GetOneByKey<PS_sbcs>(gtsbtemp.sbType + ilisttemp[0].ToString()); //if (sbcstemp != null) //{ //ex.SetCellValue(sbcstemp.xh + "/" + icount.ToString(), ihang + j + 1, jlie); //} byqrl += gtsbtemp.byqCapcity; if (gtsbtemp.byqModle.IndexOf("-") < 0) { ex.SetCellValue(gtsbtemp.byqModle /*+ "/" + icount.ToString()*/, ihang + 1, jlie + j); //ex.SetCellValue(/*gtsbtemp.byqModle + "/" +*/ icount.ToString(), ihang+j + 2, jlie); //ex.SetCellValue(gtsbtemp.byqCapcity.ToString(), ihang+j + 3, jlie); } else { ex.SetCellValue(gtsbtemp.byqModle.Substring(0, gtsbtemp.byqModle.IndexOf("-")) /*+ "/"+ icount.ToString()*/, ihang + 1, jlie + j); } } } ex.SetCellValue(icount.ToString(), ihang + 2, jlie); ex.SetCellValue(byqrl.ToString(), ihang + 3, jlie); } } ihang += btRowCount + 3; //避雷器型号/数量 if (blqlist != null && blqlist.Count > 0) { if (blqlist.Count > blqRowCount) { for (j = blqRowCount; j < blqlist.Count; j++) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + blqRowCount, "A"], xx.Cells[ihang + blqRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]); range.Merge(Type.Missing); } for (int jtem = 0; jtem < blqlist.Count; jtem++) { for (int item = 0; item < 29; item += 2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]); range.Merge(Type.Missing); } } blqRowCount = blqlist.Count; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + blqRowCount - 1, 1]); range.Merge(Type.Missing); } for (j = 0; j < blqlist.Count; j++) { int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select sum(sbNumber) from PS_gtsb Where sbModle = '" + blqlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'")); // int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbModle = '" + blqlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); ex.SetCellValue(blqlist[j].ToString(), ihang + j, jlie); ex.SetCellValue(icount.ToString(), ihang + j + 1, jlie); } } ihang += blqRowCount + 1; //开关型号/数量 if (kglist != null && kglist.Count > 0) { if (kglist.Count > kgRowCount) { for (j = kgRowCount; j < kglist.Count; j++) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + kgRowCount, "A"], xx.Cells[ihang + kgRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftDown, Type.Missing); range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]); range.Merge(Type.Missing); } for (int jtem = 0; jtem < kglist.Count; jtem++) { for (int item = 0; item < 29; item += 2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]); range.Merge(Type.Missing); } } kgRowCount = kglist.Count; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + kgRowCount - 1, 1]); range.Merge(Type.Missing); } for (j = 0; j < kglist.Count; j++) { try { //int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select sum(sbNumber) from PS_gtsb Where sbModle = '" + kglist[j].ToString() + "' and gtID='" + gtobj.gtID + "'")); //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_kg>(" Where kgModle = '" + kglist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); ex.SetCellValue(kglist[j].ToString(), ihang + j, jlie); } catch { } } ex.SetCellValue(kglist.Count.ToString(), ihang + 2, jlie); } ihang += kgRowCount + 2; jlie += 2; } //#region 画图形 //dsoFramerWordControl1.FileOpen(outfname); //Microsoft.Office.Interop.Excel.Workbook wb; //Microsoft.Office.Interop.Excel.Worksheet xx; //try //{ // wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; // xx = wb.Application.Sheets[1] as Microsoft.Office.Interop.Excel.Worksheet; //} //catch (Exception err) //{ // dsoFramerWordControl1.FileClose(); // throw new Exception("excel的打开方式不对,有可能装有wps", err); //} //Excel.Range range; //if (lieindex < 1) // range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, ColumnCount]); //else // range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, lieindex + 2]); //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous; //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Excel.XlBorderWeight.xlThick; //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].LineStyle = Excel.XlLineStyle.xlContinuous; //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].Weight = Excel.XlBorderWeight.xlThick; //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Excel.XlLineStyle.xlContinuous; //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Excel.XlBorderWeight.xlThick; ex.ActiveSheet(1); } catch (Exception exmess) { MsgBox.ShowTipMessageBox(exmess.Message.ToString()); } dsoFramerWordControl1.FileSave(); pj17.BigData = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.Dispose(); //#endregion //System.Diagnostics.Process.Start(outfname); return 1; }
public void ExportExcelSubmit(DateTime dt,DateTime dt2, ref LP_Temple parentTemple, string orgid, bool isShow) { DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string fname = Application.StartupPath + "\\00记录模板\\所月度停电计划.xls"; dsoFramerWordControl1.FileOpen(fname); string startday = "20"; IList list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", string.Format("select nr from pj_dyk where dx='所月度停电计划' and sx like '%{0}%' and nr!=''", "申报截止日期")); if (list.Count > 0) startday = list[0].ToString(); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent; ExcelAccess ex = new ExcelAccess(); Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ex.MyWorkBook = wb; ex.MyExcel = wb.Application; string filter = " where (TDtime between '" + dt.Year + "-" + dt.Month + "-" + dt.Day + " 00:00:00' and '" + dt2.Year + "-" + dt2.Month + "-" + dt2.Day + " 23:59:59') "; if (orgid != "") filter += " and OrgCode='" + orgid + "'"; if (isWorkflowCall) { filter = filter + " and (id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "') " + " or id in (select ModleRecordID from WF_ModleRecordWorkTaskIns where " + " RecordID='" + currRecord.ID + "')) " ; } IList<PJ_tdjh> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_tdjh>( filter ); ExportExcel(dt,ex, datalist); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } dsoFramerWordControl1.FileSave(); parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); }
void gridViewOperation_AfterEdit(PJ_23 obj) { //修改模板 mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(obj.ParentID); string fname = Application.StartupPath + "\\00记录模板\\23配电线路产权维护范围协议书.xls"; string bhname = org.OrgName.Replace("供电所", ""); DSOFramerControl dsoFramerControl1 = new DSOFramerControl(); dsoFramerControl1.FileOpen(fname); Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; //PJ_23 obj1 = (PJ_23)MainHelper.PlatformSqlMap.GetObject("SelectPJ_23List", "where ParentID='" + obj.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "-" + DateTime.Now.Year.ToString() + "-%' order by xybh ASC"); //int icount = 1; //if (obj1 != null && obj1.xybh != "") //{ // //icount = Convert.ToInt32(obj.xybh.Split('-')[2]) + 1; //} string strname = obj.xybh;// SelectorHelper.GetPysm(bhname, true); ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; ea.SetCellValue(strname.ToUpper(), 4, 8); //strname = DateTime.Now.Year.ToString(); //ea.SetCellValue(strname, 4, 9); //strname = string.Format("{0:D3}", icount); //ea.SetCellValue(strname, 4, 10); ea.SetCellValue(obj.cqdw + ":", 6, 4); ea.SetCellValue(obj.linename, 10, 7); ea.SetCellValue(obj.fzlinename, 10, 10); ea.SetCellValue("'" + obj.gh, 10, 16); ea.SetCellValue(obj.cqfw, 11, 4); ea.SetCellValue(obj.cqdw, 13, 4); ea.SetCellValue(obj.qdrq.Year.ToString(), 21, 7); ea.SetCellValue(obj.qdrq.Month.ToString(), 21, 9); ea.SetCellValue(obj.qdrq.Day.ToString(), 21, 11); dsoFramerControl1.FileSave(); obj.BigData = dsoFramerControl1.FileData; dsoFramerControl1.FileClose(); dsoFramerControl1.Dispose(); dsoFramerControl1 = null; MainHelper.PlatformSqlMap.Update<PJ_23>(obj); }
private void btnOK_Click(object sender, EventArgs e) { //if (comboBoxEdit1.Text == "") //{ // MsgBox.ShowTipMessageBox("变动地点不能为空。"); // comboBoxEdit1.Focus(); // return; //} ////if (rowData.BigData == null) ////{ //// rowData.BigData = new byte[0]; ////} //this.DialogResult = DialogResult.OK; //this.Close(); string strmes = ""; DSOFramerControl dsoFramerControl1 = new DSOFramerControl(); Microsoft.Office.Interop.Excel.Workbook wb; if (rowData.BigData == null || rowData.BigData.Length == 0) { string fname = Application.StartupPath + "\\00记录模板\\24设备变更通知书.xls"; dsoFramerControl1.FileOpen(fname); } else dsoFramerControl1.FileData = rowData.BigData; wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; DateTime dt = Convert.ToDateTime(dateEdit1.EditValue); ea.SetCellValue(dt.Year.ToString(), 4, 7); mOrg org = MainHelper.PlatformSqlMap.GetOne<mOrg>(" where orgid='" + rowData.ParentID + "'"); if (org != null) ea.SetCellValue(org.OrgName,4, 9); ea.SetCellValue(dt.Year.ToString(), 9, 1); ea.SetCellValue(dt.Month.ToString(), 9, 3); ea.SetCellValue(dt.Day.ToString(), 9, 5); ea.SetCellValue(comboBoxEdit1.Text, 6, 7); ea.SetCellValue(memoEdit1.Text, 6, 8); ea.SetCellValue(memoEdit2.Text, 6, 11); dsoFramerControl1.FileSave(); rowData.BigData = dsoFramerControl1.FileData; dsoFramerControl1.FileClose(); dsoFramerControl1.Dispose(); dsoFramerControl1 = null; MainHelper.PlatformSqlMap.Update<PJ_24>(rowData); currRecord.LastChangeTime = DateTime.Now.ToString(); if (RecordWorkTask.CheckOnRiZhi(WorkFlowData)) { RecordWorkTask.CreatRiZhi(WorkFlowData, null, currRecord.ID, new object[] { rowData, currRecord }); } WF_WorkTaskCommands wt; //string[] strtemp = RecordWorkTask.RunNewGZPRecord(currRecord.ID, kind, MainHelper.User.UserID); wt = (WF_WorkTaskCommands)MainHelper.PlatformSqlMap.GetObject("SelectWF_WorkTaskCommandsList", " where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'"); if (wt != null) { strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), wt.CommandName); } else { strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), "提交"); } if (strmes.IndexOf("未提交至任何人") > -1) { MsgBox.ShowTipMessageBox("未提交至任何人,创建失败,请检查流程模板和组织机构配置是否正确!"); return; } else MsgBox.ShowTipMessageBox(strmes); strmes = RecordWorkTask.GetWorkFlowTaskCaption(WorkFlowData.Rows[0]["WorkTaskInsId"].ToString()); if (strmes == "结束节点1") { currRecord.Status = "存档"; } else { currRecord.Status = strmes; } if (currRecord.ImageAttachment == null) { currRecord.ImageAttachment = new byte[0]; } if (currRecord.DocContent == null) { currRecord.DocContent = new byte[0]; } if (currRecord.SignImg == null) { currRecord.SignImg = new byte[0]; } currRecord.LastChangeTime = DateTime.Now.ToString(); if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0]; if (currRecord.SignImg == null) currRecord.SignImg = new byte[0]; MainHelper.PlatformSqlMap.Update("UpdateLP_Record", currRecord); }
private void btExport0_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridView1.GetFocusedRow() == null) return; xxgx_aqxpj obj = gridView1.GetFocusedRow() as xxgx_aqxpj; string fname = ""; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; try { DSOFramerControl ds1 = new DSOFramerControl(); ds1.FileDataGzip = obj.filedata; ds1.FileSave(fname, true); ds1.FileClose(); if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } catch (Exception ex) { Console.WriteLine(ex.Message); MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); return; } } }
private void barReExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridView1.FocusedRowHandle < 0) return; DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle); LP_Record currRecord = new LP_Record(); int i = 0; //string exploreKind = ""; foreach (DataColumn dc in gridtable.Columns) { if (dc.ColumnName != "Image") { if (dc.DataType.FullName.IndexOf("Byte[]") < 0) currRecord.GetType().GetProperty(dc.ColumnName).SetValue(currRecord, dr[dc.ColumnName], null); else if (dc.DataType.FullName.IndexOf("Byte[]") > -1 && DBNull.Value != dr[dc.ColumnName] && dr[dc.ColumnName].ToString() != "") currRecord.GetType().GetProperty(dc.ColumnName).SetValue(currRecord, dr[dc.ColumnName], null); } } DataTable dt = RecordWorkTask.GetRecordWorkFlowData(dr["ID"].ToString(), MainHelper.User.UserID); IList<WFP_RecordWorkTaskIns> wf = MainHelper.PlatformSqlMap.GetList<WFP_RecordWorkTaskIns>("SelectWFP_RecordWorkTaskInsList", "where RecordID='" + currRecord.ID + "'"); if (currRecord.Status != "存档") { if (dt.Rows.Count > 0) { if (!RecordWorkTask.HaveWorkFlowAllExploreRole(dt.Rows[0]["WorkTaskId"].ToString(), dt.Rows[0]["WorkFlowId"].ToString())) { if (!RecordWorkTask.HaveRunRecordRole(currRecord.ID, MainHelper.User.UserID)) { MsgBox.ShowWarningMessageBox("没有运行权限,导出失败!"); return; } if (!RecordWorkTask.HaveWorkFlowExploreRole(dt.Rows[0]["WorkTaskId"].ToString(), dt.Rows[0]["WorkFlowId"].ToString())) { MsgBox.ShowWarningMessageBox("没有导出权限,导出失败!"); return; } } } else { MsgBox.ShowTipMessageBox("无当前用户可以操作此记录的流程信息,导出失败!"); return; } }//流程没结束 else if (!RecordWorkTask.HaveFlowEndExploreRole(currRecord.Kind)) { MsgBox.ShowTipMessageBox("流程结束后不允许导出,导出失败!"); return; }//流程结束 if (currRecord.ID.IndexOf("N") == -1 || parentObj.FlowCaption.IndexOf("定期分析") > -1 || parentObj.FlowCaption.IndexOf("专题分析") > -1) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname = ""; saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; try { DSOFramerControl ds1 = new DSOFramerControl(); ds1.FileDataGzip = currRecord.DocContent; ds1.FileSave(fname, true); ds1.FileClose(); if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } catch (Exception ex) { Console.WriteLine(ex.Message); MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); } } return; }//是旧记录 Hashtable templehs = RecordWorkTask.GetExploerLP_TempleList(dt, currRecord); if (templehs.Count > 1) { DataTable templedt = new DataTable(); templedt.Columns.Add("Checked", typeof(bool)); templedt.Columns.Add("Index", typeof(string)); templedt.Columns.Add("Name", typeof(string)); ArrayList akeys = new ArrayList(templehs.Keys); for (i = 0; i < akeys.Count; i++) { object obj = akeys[i]; DataRow templedr = templedt.NewRow(); if (obj is LP_Temple) { WF_WorkTask wt = MainHelper.PlatformSqlMap.GetOneByKey<WF_WorkTask>(templehs[akeys[i]]); if (wt != null) { templedr["Name"] = wt.TaskCaption + "-申报表单"; templedr["Checked"] = 1; templedr["Index"] = i; templedt.Rows.Add(templedr); } } else if (obj is string) { LP_Temple taskTemple = MainHelper.PlatformSqlMap.GetOneByKey<LP_Temple>(templehs[akeys[i]]); if (taskTemple != null) { templedr["Name"] = taskTemple.CellName; templedr["Checked"] = 1; templedr["Index"] = i; templedt.Rows.Add(templedr); } } } frmExploreSelect frmes = new frmExploreSelect(); frmes.SourceDt = templedt; if (frmes.ShowDialog() == DialogResult.OK && frmes.CheckIndehs.Count > 0) { string fname = ""; FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { fname = fbd.SelectedPath + "\\"; ArrayList checkkeys = new ArrayList(frmes.CheckIndehs.Keys); for (i = 0; i < checkkeys.Count; i++) { object obj = akeys[Convert.ToInt32(checkkeys[i])]; DSOFramerControl ds1 = new DSOFramerControl(); try { if (obj is LP_Temple) { ds1.FileDataGzip = ((LP_Temple)obj).DocContent; //ds1.FileOpen(ds1.FileName); ds1.FileSave(CheckFileName(fname + frmes.CheckIndehs[checkkeys[i]]), true); ds1.FileClose(); } else if (obj is string) { LP_Temple taskTemple = MainHelper.PlatformSqlMap.GetOneByKey<LP_Temple>(templehs[akeys[i]]); if (taskTemple != null) { RecordWorkTask.iniTableRecordData(ref taskTemple, currRecord, wf[0].WorkFlowId, wf[0].WorkFlowInsId, true); ds1.FileDataGzip = taskTemple.DocContent; //ds1.FileOpen(ds1.FileName); ds1.FileSave(CheckFileName(fname + taskTemple.CellName), true); ds1.FileClose(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); MsgBox.ShowWarningMessageBox("无法保存" + frmes.CheckIndehs[checkkeys[i]] + "。请用其他文件名保存文件,或将文件存至其他位置。"); } }//循环所有选择的表单 if (MsgBox.ShowAskMessageBox("导出成功,是否所在文件夹?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } } }//表单不止一个 else { ArrayList akeys = new ArrayList(templehs.Keys); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname = ""; saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; try { DSOFramerControl ds1 = new DSOFramerControl(); if (akeys[0] is LP_Temple) { ds1.FileDataGzip = ((LP_Temple)akeys[0]).DocContent; ds1.FileSave(fname, true); ds1.FileClose(); } else if (akeys[0] is string) { LP_Temple taskTemple = MainHelper.PlatformSqlMap.GetOneByKey<LP_Temple>(akeys[0]); if (taskTemple != null) { WF_WorkTaskControls wtc = MainHelper.PlatformSqlMap.GetOne<WF_WorkTaskControls>(" where WorkflowId='" + wf[0].WorkFlowId + "' and WorktaskId='" + wf[0].WorkTaskId + "'"); if (wtc != null) { } RecordWorkTask.iniTableRecordData(ref taskTemple, currRecord, wf[0].WorkFlowId, wf[0].WorkFlowInsId, true); ds1.FileDataGzip = taskTemple.DocContent; ds1.FileSave(fname, true); ds1.FileClose(); } } if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } catch (Exception ex) { Console.WriteLine(ex.Message); MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); return; } } } }
public void ExportExcelSubmit(ref LP_Temple parentTemple, string orgid, bool isShow) { DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string fname = Application.StartupPath + "\\00记录模板\\线路设备责任区划分明白表.xls"; dsoFramerWordControl1.FileOpen(fname); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent; ExcelAccess ex = new ExcelAccess(); Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ex.MyWorkBook = wb; ex.MyExcel = wb.Application; string filter = ""; int i = 0; string sdtrorg = " "; if (orgid != "") { sdtrorg += " and OrgCode='" + orgid + "'"; } IList mclist = ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct zrr from PJ_xlsbzrqhfmbb where 1=1 " + sdtrorg); List<WF_ModleRecordWorkTaskIns> mrwtlist = new List<WF_ModleRecordWorkTaskIns>(); foreach (string mc in mclist) { filter = " where 1=1 and zrr='" + mc + "' "; if (orgid != "") filter = " and OrgCode='" + orgid + "'"; if (isWorkflowCall) { filter = filter + " and (id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where WorkFlowInsId='" + WorkFlowData.Rows[0]["WorkFlowInsId"].ToString() + "') " + " or id in (select ModleRecordID from WF_ModleRecordWorkTaskIns where " + " RecordID='" + currRecord.ID + "')) " ; } IList<PJ_xlsbzrqhfmbb> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_xlsbzrqhfmbb>( filter ); ExportExcel(ex, datalist,mc); } ex.DeleteSheet(1); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } dsoFramerWordControl1.FileSave(); parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); }
public static int ExportToExcel(string title, string dw, sdjls_sbpjb pj17) { string fname = Application.StartupPath + "\\00记录模板\\送管22送电线路设备评级表.xls"; DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string outfname = Path.GetTempFileName() + ".xls"; File.Copy(fname, outfname); dsoFramerWordControl1.FileOpen(outfname); Microsoft.Office.Interop.Excel.Worksheet xx; Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; ExcelAccess ex = new ExcelAccess(); ex.MyWorkBook = wb; ex.MyExcel = wb.Application; sd_xl xl = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineCode='" + pj17.LineCode + "'"); try { if (xl == null) { MsgBox.ShowWarningMessageBox("数据出错,没找到线路"); return -1; } string strLinexh = xl.WireType;//导线型号 //IList<sd_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<sd_gt>(" Where LineCode='" + xl.LineCode + "' order by gtcode"); int gtcount = Client.ClientHelper.PlatformSqlMap.GetRowCount<sd_gt>(" Where LineCode='" + xl.LineCode + "'"); ex.ActiveSheet(1); //设置线路值 ex.SetCellValue(xl.LineName, 3, 3); ex.SetCellValue(xl.LineVol, 3, 8); ex.SetCellValue(xl.WireLength.ToString(), 3, 11); ex.SetCellValue(xl.InDate.Year + "年" + xl.InDate.Month + "月", 3, 13); //ex.SetCellValue(xl.InDate.Year.ToString(), 4, 9); //ex.SetCellValue(xl.InDate.Month.ToString(), 4, 11); //评级日期 ex.SetCellValue(DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日", 4, 3); //杆塔 ex.SetCellValue(gtcount.ToString(), 5, 3);//合计 ex.SetCellValue(gtcount.ToString(), 6, 3);//一类 //导地线 ex.SetCellValue(xl.WireLength.ToString(), 9, 3);//合计 ex.SetCellValue(xl.WireLength.ToString(), 10, 3);//一类 //绝缘子 string sql = "in ("; //foreach (sd_gt gt in gtlis) //{ // sql+="'"+gt.gtID+"',"; //} //sql = sql.Substring(0, sql.Length - 1) + ")"; sql = "in (select gtid from sd_gt Where LineCode='" + xl.LineCode + "' )"; string strSQL = "select sbid from sd_gtsb Where gtID " + sql; IList jdzzList = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL); strSQL += " and ("+getNamesql()+")"; IList jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL); ex.SetCellValue(jyuzlist.Count.ToString(), 13, 3); ex.SetCellValue(jyuzlist.Count.ToString(), 14, 3); //接地装置 ex.SetCellValue(jdzzList.Count.ToString(), 17, 3); ex.SetCellValue(jdzzList.Count.ToString(), 18, 3); //其它 //评定等级 ex.SetCellValue("一级", 24, 3); //评级负责人 if (MainHelper.User != null) { ex.SetCellValue(MainHelper.User.UserName, 25, 3); } } catch (Exception exmess) { MsgBox.ShowTipMessageBox(exmess.Message.ToString()); } dsoFramerWordControl1.FileSave(); pj17.BigData = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.Dispose(); //#endregion //System.Diagnostics.Process.Start(outfname); return 1; }
private void barReExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridView1.FocusedRowHandle < 0) return; DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle); LP_Record currRecord = new LP_Record(); foreach (DataColumn dc in gridtable.Columns) { if (dc.ColumnName != "Image") { if (dc.DataType.FullName.IndexOf("Byte[]") < 0) currRecord.GetType().GetProperty(dc.ColumnName).SetValue(currRecord, dr[dc.ColumnName], null); else if (dc.DataType.FullName.IndexOf("Byte[]") > -1 && DBNull.Value != dr[dc.ColumnName] && dr[dc.ColumnName].ToString() != "") currRecord.GetType().GetProperty(dc.ColumnName).SetValue(currRecord, dr[dc.ColumnName], null); } } if (currRecord.ID.IndexOf("N") > -1) { MsgBox.ShowTipMessageBox("此记录由新模块创建,请使用新模块操作!"); return; } if (currRecord.Status != "存档") { MsgBox.ShowTipMessageBox("安监未审核,不能导出!"); return; } SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname = ""; saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; try { DSOFramerControl ds1 = new DSOFramerControl(); ds1.FileDataGzip = currRecord.DocContent ; //ds1.FileOpen(ds1.FileName); ds1.FileSave(fname,true); ds1.FileClose(); ExcelAccess ea = new ExcelAccess(); ea.Open(fname); char pchar = '|'; Excel.Workbook wb = ds1.AxFramerControl.ActiveDocument as Excel.Workbook; Excel.Worksheet xx = wb.Application.Sheets[1] as Excel.Worksheet; IList<LP_Temple> templeList = MainHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList", "where ParentID ='" + ParentObj.LPID + "' and isExplorer='1' Order by SortID"); LockExcel(ea); unLockExcel(ea); foreach (LP_Temple lp in templeList) { string[] arrCellpos = lp.CellPos.Split(pchar); for (int i = 0; i < arrCellpos.Length && arrCellpos[i] != ""; i++) { ea.SetCellValue("", GetCellPos(arrCellpos[i])[0], GetCellPos(arrCellpos[i])[1]); } } ea.ShowExcel(); ds1.FileClose(); ds1.Dispose (); } catch(Exception ex) { Console.WriteLine(ex.Message ); MsgBox.ShowWarningMessageBox ("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); return; } } }
public static int ExportToExcel(string title, string dw, sdjl_21 pj17) { string fname = Application.StartupPath + "\\00记录模板\\送电21线路条图.xls"; float fxstart = 0, fystart = 0, fwidth = 0, fheight = 0; DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string outfname = Path.GetTempFileName() + ".xls"; File.Copy(fname, outfname); dsoFramerWordControl1.FileOpen(outfname); Microsoft.Office.Interop.Excel.Worksheet xx; Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; ExcelAccess ex = new ExcelAccess(); ex.MyWorkBook = wb; ex.MyExcel = wb.Application; sd_xl xl = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineCode='" + pj17.LineCode + "'"); Dictionary<int, NZLength> Dic = new Dictionary<int, NZLength>(); try { if (xl == null) { MsgBox.ShowWarningMessageBox("数据出错,没找到线路"); return -1; } string strLinexh = xl.WireType;//导线型号 sd_gt gtformer = null; IList<sd_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<sd_gt>(" Where LineCode='" + xl.LineCode + "' order by gtcode"); int h = 1; int start = -1; int end = -1; bool notStart=true; decimal sums = 0; foreach (sd_gt gt in gtlis) { if (gt.gtModle != "直线杆") { if (notStart) { start = h; notStart = false; } sums += gt.gtSpan; } else { notStart = true; end = h - 1; if (start > 0) { Dic.Add(h, new NZLength{Start = start,End = end,Sum = sums}); } start = -1; end = -1; sums = 0; } h++; } gtformer = Client.ClientHelper.PlatformSqlMap.GetOne<sd_gt>(" Where gtID='" + xl.ParentGT + "'"); gtlis.Insert(0, gtformer); //计算页码 int pagecount = 1, jmax = 15, m = 0, j = 0; pagecount = gtlis.Count / 15 + 1; int ihang = 8, jlie = 2; int i = 0; //复制空模板 for (m = 1; m < pagecount; m++) { ex.CopySheet(1, m); ex.ReNameWorkSheet(m + 1, "Sheet" + (m + 1)); } string[] strname = new string[3]; strname[0] = ""; strname[1] = ""; strname[2] = ""; if (xl.LineType == "1") { strname[0] = xl.LineName.Split('线')[0] + "线"; strname[1] = xl.LineName.Replace(strname[0], ""); } else if (xl.LineType == "2") { sd_xl xltemp = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineID='" + xl.ParentID + "'"); if (xltemp != null) strname[0] = xltemp.LineName; strname[1] = xl.LineName.Replace(xltemp.LineName,""); } else if (xl.LineType == "3") { strname[2] = xl.LineName; sd_xl xltemp = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineID='" + xl.ParentID + "'"); if (xltemp != null) { strname[1] = xltemp.LineName; xltemp = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineID='" + xltemp.ParentID + "'"); if (xltemp != null) strname[0] = xltemp.LineName; } strname[2].Replace(strname[1], ""); strname[1].Replace(strname[0], ""); } //填写公共项 for (m = 1; m <= pagecount; m++) { ex.ActiveSheet("Sheet" + m); if(!string.IsNullOrEmpty(strname[0])) ex.SetCellValue(strname[0], 3, 3); if (!string.IsNullOrEmpty(strname[1])) ex.SetCellValue(strname[1], 3, 5); if (!string.IsNullOrEmpty(strname[2])) ex.SetCellValue(strname[2], 3, 11); ex.SetCellValue(xl.LineVol.ToString(), 3, 20); } ihang = 8; jlie = 3; int hdRowCount = 1; int jyzRowCount = 1; int dxRowCount = 1; int lxRowCount = 1; int jstart = 3; double dc = 0; string strfx = ""; Excel.Range range; for (i = 1; i < gtlis.Count; i++) { if ((i + 0.0) % (jmax) == 1) { jlie = 3; ihang = 8; hdRowCount = 1; jyzRowCount = 1; dxRowCount = 1; lxRowCount = 1; } if (Math.Ceiling((i + 0.0) / (jmax)) > 1) { ex.ActiveSheet("Sheet" + Math.Ceiling((i + 0.0) / (jmax))); xx = wb.Application.Sheets["Sheet" + Math.Ceiling((i + 0.0) / (jmax))] as Microsoft.Office.Interop.Excel.Worksheet; } else { ex.ActiveSheet("Sheet1"); xx = wb.Application.Sheets["Sheet1"] as Microsoft.Office.Interop.Excel.Worksheet; } //ex.SetCellValue(i.ToString(), ihang, jlie); ////杆塔数 sd_gt gtobj = gtlis[i]; //绝缘子 //string strSQL = "select distinct sbModle from sd_gtsb Where gtID='" + gtobj.gtID + "' "; //if (xl.LineVol != "" && Convert.ToDouble(xl.LineVol) >= 10) { // strSQL += " and (sbName like '高压%立瓶%' or sbName like '高压%悬垂%' or sbName like '高压%茶台%' )"; //} else // if (xl.LineVol != "" && 0.4 >= Convert.ToDouble(xl.LineVol)) { // strSQL += " and (sbName like '低压%立瓶%' or sbName like '低压%茶台%' )"; // } string strSQL = "select distinct sbModle from sd_gtsb Where gtID='" + gtobj.gtID + "' "; if (xl.LineVol != "" && Convert.ToDouble(xl.LineVol) >= 10) { strSQL += " and (sbName like '%绝缘子%' or sbName like '高压%立瓶%' or sbName like '高压%悬垂%' or sbName like '高压%茶台%' )"; } else if (xl.LineVol != "" && 0.4 >= Convert.ToDouble(xl.LineVol)) { strSQL += " and (sbName like '低压%立瓶%' or sbName like '%绝缘子%' or sbName like '低压%茶台%' )"; } IList jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL); //导线型号 IList dxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbModle from sd_gtsb Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'"); //导线排列方式 IList dxpllist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct C1 from sd_gtsb Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'"); //耐张规格 IList hdobj = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from sd_gtsb Where sbName like '%耐张%' and gtID='" + gtobj.gtID + "'"); //拉线规格 //IList lxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from sd_gtsb Where sbName like '%拉线%' and gtID='" + gtobj.gtID + "'"); IList lxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneInt", " select sum(sbnumber) from sd_gtsb where sbName like '%拉线%' and gtID='" + gtobj.gtID + "'"); ihang = 8; ////杆号 ex.SetCellValue((i).ToString(), ihang, jlie); ihang++; //转角方向 if (gtobj.gtModle.IndexOf("转角") > -1) { if (i != 1 && i < gtlis.Count - 1) { decimal[,] a1 = new decimal[1, 2]; decimal[,] a2 = new decimal[1, 2]; a1[0, 0] = gtlis[i].gtLat - gtlis[i - 1].gtLat; a1[0, 1] = gtlis[i].gtLon - gtlis[i - 1].gtLon; a2[0, 0] = gtlis[i + 1].gtLat - gtlis[i].gtLat; a2[0, 1] = gtlis[i + 1].gtLon - gtlis[i].gtLon; decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1]; double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble( a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1]))); dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0); if (gtlis[i].gtLon > gtlis[i - 1].gtLon) { strfx = "右转"; } else { strfx = "左转"; } if (dc.ToString() != "NaN" && dc.ToString() != "非数字") ex.SetCellValue(strfx + dc + "度", ihang, jlie); else { } } } ihang++; //杆高(m) if (gtobj != null) { ex.SetCellValue(gtobj.gtHeight.ToString(), ihang, jlie); } ihang++; //电杆种类/杆型 if (gtobj != null) { string strtype = "", strzj = ""; if (gtobj.gtType.IndexOf("混凝土拔梢杆") > -1) { strtype = "砼"; } if (gtobj.gtModle.IndexOf("直线杆") > -1) { strzj = "直"; } else if (gtobj.gtModle.IndexOf("分支杆") > -1) { strzj = "分"; } else if (gtobj.gtModle.IndexOf("转角杆") > -1) { strzj = "转"; } else if (gtobj.gtModle.IndexOf("耐张杆") > -1) { strzj = "耐"; } else if (gtobj.gtModle.IndexOf("终端杆") > -1) { strzj = "终"; } if (strtype != "" && strzj != "") { ex.SetCellValue(strtype + "/" + strzj, ihang, jlie); } else { ex.SetCellValue(gtobj.gtType + "/" + gtobj.gtModle, ihang, jlie); } } ihang++; //导线排列方式 //if (hdobj.Count>0 && hdobj[0].ToString().Contains("三角")) { // ex.SetCellValue("三角排列", ihang, jlie); //} else { // ex.SetCellValue("水平排列", ihang, jlie); //} ex.SetCellValue(xl.c1, ihang, jlie); ihang++; //导线型号规格(mm2) if (dxlist != null && dxlist.Count > 0) { if (dxlist.Count > dxRowCount) { for (j = dxRowCount; j < dxlist.Count; j++) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + dxRowCount, "A"], xx.Cells[ihang + dxRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); } for (int jtem = 1; jtem < dxlist.Count; jtem++) { for (int item = 0; item < 29; item += 2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]); range.Merge(Type.Missing); } } dxRowCount = dxlist.Count; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + dxRowCount - 1, 1]); range.Merge(Type.Missing); } if (dxlist.Count > 0) { for (j = 0; j < dxlist.Count; j++) ex.SetCellValue(dxlist[j].ToString(), ihang + j, jlie); } } else { ex.SetCellValue(strLinexh, ihang, jlie); } ihang += dxRowCount; if (i == 15) { int nn = 0; } //档 距(m) if (gtobj != null && gtobj.gtSpan>0) { if (jlie > 3) ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie - 1); else ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie); } ihang++; //耐张段长度 ihang += hdRowCount; //累计长度 if (((i + 0.0) % (jmax) == 0 && i > 1) || i == gtlis.Count - 1) { //累计长度 double sum = 0; int ista = i, item = i; for (item = i; item > 0; item--) { sd_gt gttemp = gtlis[item]; if (gttemp != null) { sum += Convert.ToDouble(gttemp.gtSpan); } if (i < gtlis.Count - 1) { if (item % jmax == 1 && ista != item) { break; } } else { if (item % jmax == 1) { break; } } } sum = 0; for (int m1 = 0; m1 < gtlis.Count;m1++ ) { sd_gt gttemp = gtlis[m1]; if (gttemp != null) { sum += Convert.ToDouble(gttemp.gtSpan); } } ex.SetCellValue(sum.ToString(), ihang, jstart); float gwidth = 13.50F, gheifht = 13.50F; //float gwidth = 10F, gheifht = 10F; Microsoft.Office.Interop.Excel.Shape activShape, oldShape = null, kywShape = null; int icolor = (int)(((uint)Color.White.B << 16) | (ushort)(((ushort)Color.White.G << 8) | Color.White.R)); range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]); fxstart = (float)Convert.ToDouble(range.Cells.Width); range = (Excel.Range)xx.get_Range(xx.Cells[6, 2], xx.Cells[6, 2]); fxstart += (float)Convert.ToDouble(range.Cells.Width); range = (Excel.Range)xx.get_Range(xx.Cells[1, 1], xx.Cells[5, 1]); fystart = (float)Convert.ToDouble(range.Cells.Height); range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]); fystart = fystart + (float)(Convert.ToDouble(range.Cells.Height) / 2); activShape = null; for (int itemp = 0; itemp <= ista - item; itemp++) { range = (Excel.Range)xx.get_Range(xx.Cells[6, itemp * 2 + jstart], xx.Cells[6, itemp * 2 + jstart + 1]); float width = (float)Convert.ToDouble(range.Cells.Width); sd_xl xl2 = Client.ClientHelper.PlatformSqlMap.GetOne<sd_xl>("where ParentGT='" + gtlis[item + itemp].gtID + "'"); if (xl2 == null) { if (gtlis[item + itemp].gtModle.IndexOf("转角") == -1) { activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht); } else { PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '直角'"); if (tb2 != null) { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb2.picImage); bw.Flush(); bw.Close(); fs.Close(); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); decimal[,] a1 = new decimal[1, 2]; decimal[,] a2 = new decimal[1, 2]; if (item + itemp < gtlis.Count) { a1[0, 0] = gtlis[item + itemp].gtLat - gtlis[item + itemp - 1].gtLat; a1[0, 1] = gtlis[item + itemp].gtLon - gtlis[item + itemp - 1].gtLon; a2[0, 0] = gtlis[item + itemp + 1].gtLat - gtlis[item + itemp].gtLat; a2[0, 1] = gtlis[item + itemp + 1].gtLon - gtlis[item + itemp].gtLon; } decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1]; double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble( a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1]))); dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0); if (gtlis[item + itemp].gtLon > gtlis[item + itemp - 1].gtLon) { strfx = "右转"; } else { strfx = "左转"; } int btw = (int)(bt.Width / 1.33f); int bth = (int)(bt.Height / 1.33f); if (btw < width / 2) { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth); if (strfx == "左转") { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 - Convert.ToDouble(dc)); } else { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 + Convert.ToDouble(dc)); } } else { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bt.Height / 2,bt.Width, bt.Height); if (strfx == "左转") { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 - Convert.ToDouble(dc)); } else { if (dc.ToString() != "NaN" && dc.ToString() != "非数字") activShape.Rotation = (float)(90 + Convert.ToDouble(dc)); } } } } } else { ex.SetCellValue(xl2.LineName, 5, itemp * 2 + 4);//分支线路 PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '分支'"); if (tb2 != null) { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb2.picImage); bw.Flush(); bw.Close(); fs.Close(); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); int btw = (int)(bt.Width / 1.33f); int bth = (int)(bt.Height / 1.33f); if (btw < width / 2) { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth); } else { activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bth / 2, btw, bth); } } else { activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht); } } //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht); activShape.Fill.ForeColor.RGB = icolor; if (itemp > 0) { //IList<sdjl_05jcky> kyxli = MainHelper.PlatformSqlMap.GetList<sdjl_05jcky>(" where gtID='" + gtlis[item + itemp].gtID + "'"); IList<PJ_05jcky> kyxli = MainHelper.PlatformSqlMap.GetList<PJ_05jcky>(" where gtID='" + gtlis[item + itemp].gtID + "'"); if (kyxli.Count == 0) { { xx.Shapes.AddLine( oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, activShape.Left, activShape.Top + activShape.Height / 2); } } else { PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + kyxli[0].kymc + "'"); if (tb != null) { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb.picImage); bw.Flush(); bw.Close(); fs.Close(); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); int btw = (int)(bt.Width / 1.33f); int bth = (int)(bt.Height / 1.33f); if (btw < width / 2) { kywShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, oldShape.Left + oldShape.Width + width / 2 - btw / 2, oldShape.Top + oldShape.Height / 2 - bth / 2, btw, bth); xx.Shapes.AddLine( oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, kywShape.Left, oldShape.Top + oldShape.Height / 2); xx.Shapes.AddLine( kywShape.Left + (float)(kywShape.Width - 2), kywShape.Top + kywShape.Height / 2, activShape.Left + 2, kywShape.Top + kywShape.Height / 2); } else { xx.Shapes.AddLine( oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, kywShape.Left, oldShape.Top + oldShape.Height / 2); xx.Shapes.AddLine( kywShape.Left + (float)(kywShape.Width - 1), kywShape.Top + kywShape.Height / 2, activShape.Left + 1, kywShape.Top + kywShape.Height / 2); } } } } //fxstart += gtwidth[itemp]; fxstart += width; oldShape = activShape; } } ihang++; //拉线规格/条数 if (lxlist != null && lxlist.Count > 0) { //if (lxlist.Count > lxRowCount) { // for (j = lxRowCount; j < lxlist.Count; j++) { // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + lxRowCount, "A"], xx.Cells[ihang + lxRowCount, "A"]); // range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); // } // for (int jtem = lxRowCount; jtem < lxlist.Count; jtem++) { // for (int item = 0; item < 29; item += 2) { // range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + item + 1]); // range.Merge(Type.Missing); // } // } // lxRowCount = lxlist.Count; // range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + lxRowCount - 1, 1]); // range.Merge(Type.Missing); //} //for (j = 0; j < lxlist.Count; j++) { // int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select sum(sbNumber) from sd_gtsb where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'")); // //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<sd_gtsb>(" Where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); // ex.SetCellValue(lxlist[j].ToString()/* + "/" + icount*/, ihang + j, jlie); //} if (lxlist[0] != null) { ex.SetCellValue(lxlist[0].ToString(), ihang, jlie); } } ihang += lxRowCount; //绝缘子型号/数量 if (jyuzlist != null) { if (jyuzlist.Count > jyzRowCount) { for (j = jyzRowCount + 1; j < jyuzlist.Count; j = j+2) { range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jyzRowCount, "A"], xx.Cells[ihang + jyzRowCount, "A"]); range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing); range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]); range.Merge(Type.Missing); } jyzRowCount = jyuzlist.Count/2 + jyuzlist.Count%2 == 0?0:1; range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + jyzRowCount - 1, 1]); range.Merge(Type.Missing); } for (j = 0; j < jyuzlist.Count; j++) { int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select sum(sbNumber) from sd_gtsb where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'")); //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<sd_gtsb>(" Where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"); ex.SetCellValue(jyuzlist[j].ToString() /*+ "/" + icount*/, ihang + j/2, jlie + j%2); ex.SetCellValue(icount.ToString(), ihang + j / 2 + 1, jlie + j % 2); } } ihang += jyzRowCount*2 ; jlie += 2; } foreach (int key in Dic.Keys) { int page = 1; int page1 = 1; NZLength nzlength = Dic[key]; int startcolumn = (nzlength.Start + 1) * 2 - 1; if (startcolumn % 32 == 0) { page = startcolumn / 32; } else { page = startcolumn / 32 + 1; } ex.ActiveSheet(page); int endcolumn = (nzlength.End + 1) * 2 - 1; if (nzlength.End % 32 == 0) { page1 = endcolumn / 32; } else { page1 = endcolumn / 32 + 1; } if (page == page1) { ex.ActiveSheet(page); ex.UnitCells(15, startcolumn % 32, 15, endcolumn % 32); ex.SetCellValue(Math.Round(nzlength.Sum/1000,3).ToString(), 15, startcolumn % 32); } else { ex.ActiveSheet(page); ex.UnitCells(15, startcolumn % 32, 15, 31); ex.SetCellValue(nzlength.Start + "到" + nzlength.End + "杆塔:" + Math.Round(nzlength.Sum/1000,3), 15, startcolumn % 32); for (int tmp = 1; tmp <= page1 - page; tmp++) { ex.ActiveSheet(page + tmp); if (tmp < page1 - page) { ex.UnitCells(15, 3,15, 31); } ex.UnitCells(15, 3, 15, (endcolumn+2) % 32); ex.SetCellValue(nzlength.Start + "到" + nzlength.End + "杆塔:" + Math.Round(nzlength.Sum/1000,3), 15, 3); } } } ex.ActiveSheet(1); } catch (Exception exmess) { MsgBox.ShowTipMessageBox(exmess.Message.ToString()); } dsoFramerWordControl1.FileSave(); pj17.BigData = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.Dispose(); //#endregion //System.Diagnostics.Process.Start(outfname); return 1; }
private void btnOK_Click(object sender, EventArgs e) { string strname = ""; string fname = ""; string bhname = ""; int icount = 1; DSOFramerControl dsoFramerControl1 = new DSOFramerControl(); Microsoft.Office.Interop.Excel.Workbook wb; ExcelAccess ea = new ExcelAccess(); if (rowData.BigData == null || rowData.BigData.Length == 0) { fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls"; dsoFramerControl1.FileOpen(fname); } else dsoFramerControl1.FileData = rowData.BigData; wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ea.MyWorkBook = wb; ea.MyExcel = wb.Application; if (rowData.BigData == null || rowData.BigData.Length == 0) { fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls"; mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(rowData.ParentID); bhname = org.OrgName.Replace("供电所", ""); PJ_26 objtemp = (PJ_26)MainHelper.PlatformSqlMap.GetObject("SelectPJ_26List", "where ParentID='" + rowData.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "-" + DateTime.Now.Year.ToString() + "-%' order by xybh ASC"); if (objtemp != null && objtemp.xybh != "") { icount = Convert.ToInt32(objtemp.xybh.Split('-')[2]) + 1; } rowData.xybh = SelectorHelper.GetPysm(bhname, true).ToUpper() + "-" + DateTime.Now.Year.ToString() + "-" + string.Format("{0:D3}", icount); strname = SelectorHelper.GetPysm(bhname, true); ea.SetCellValue(strname.ToUpper(), 4, 9); strname = DateTime.Now.Year.ToString(); ea.SetCellValue(strname, 4, 11); strname = string.Format("{0:D3}", icount); ea.SetCellValue(strname, 4, 13); } ea.SetCellValue(comboBoxEdit1.Text + ":", 5, 2); ea.SetCellValue(comboBoxEdit3.Text, 6, 11); if (memoEdit2.Text.Length > 25) { ea.SetCellValue(memoEdit2.Text.Substring(0, 25), 7, 3); ea.SetCellValue(memoEdit2.Text.Substring(26), 8, 2); } else { ea.SetCellValue(memoEdit2.Text, 7, 3); } if (memoEdit3.Text.Length > 23) { ea.SetCellValue(memoEdit3.Text.Substring(0, 23), 13, 4); ea.SetCellValue(memoEdit3.Text.Substring(24), 14, 2); } else { ea.SetCellValue(memoEdit3.Text, 13, 4); } dsoFramerControl1.FileSave(); rowData.BigData = dsoFramerControl1.FileData; dsoFramerControl1.FileClose(); dsoFramerControl1.Dispose(); dsoFramerControl1 = null; PJ_26 sbxs = RowData as PJ_26; string strmes = ""; object obj = MainHelper.PlatformSqlMap.GetOneByKey<PJ_26>(sbxs.ID); if (obj == null) { MainHelper.PlatformSqlMap.Create<PJ_26>(sbxs); WF_ModleRecordWorkTaskIns mrwt = new WF_ModleRecordWorkTaskIns(); mrwt.ModleRecordID = sbxs.ID; mrwt.RecordID = currRecord.ID; mrwt.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString(); mrwt.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString(); mrwt.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString(); mrwt.ModleTableName = sbxs.GetType().ToString(); mrwt.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(); mrwt.CreatTime = DateTime.Now; MainHelper.PlatformSqlMap.Create<WF_ModleRecordWorkTaskIns>(mrwt); } else { MainHelper.PlatformSqlMap.Update<PJ_26>(sbxs); } currRecord.LastChangeTime = DateTime.Now.ToString(); if (RecordWorkTask.CheckOnRiZhi(WorkFlowData)) { RecordWorkTask.CreatRiZhi(WorkFlowData, null, currRecord.ID, new object[] { rowData, currRecord }); } WF_WorkTaskCommands wt; if (RecordWorkTask.CheckOnRiZhi(WorkFlowData)) { RecordWorkTask.CreatRiZhi(WorkFlowData, null, currRecord.ID, new object[] { sbxs, currRecord }); } //string[] strtemp = RecordWorkTask.RunNewGZPRecord(currRecord.ID, kind, MainHelper.User.UserID); wt = (WF_WorkTaskCommands)MainHelper.PlatformSqlMap.GetObject("SelectWF_WorkTaskCommandsList", " where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'"); if (wt != null) { strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), wt.CommandName); } else { strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), "提交"); } if (strmes.IndexOf("未提交至任何人") > -1) { MsgBox.ShowTipMessageBox("未提交至任何人,创建失败,请检查流程模板和组织机构配置是否正确!"); return; } else MsgBox.ShowTipMessageBox(strmes); strmes = RecordWorkTask.GetWorkFlowTaskCaption(WorkFlowData.Rows[0]["WorkTaskInsId"].ToString()); if (strmes == "结束节点1") { currRecord.Status = "存档"; } else { currRecord.Status = strmes; } if (currRecord.ImageAttachment == null) { currRecord.ImageAttachment = new byte[0]; } if (currRecord.DocContent == null) { currRecord.DocContent = new byte[0]; } if (currRecord.SignImg == null) { currRecord.SignImg = new byte[0]; } currRecord.LastChangeTime = DateTime.Now.ToString(); if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0]; if (currRecord.SignImg == null) currRecord.SignImg = new byte[0]; MainHelper.PlatformSqlMap.Update("UpdateLP_Record", currRecord); }
private void GetFileList(DSOFramerControl ds1, string strCurDir) { DirectoryInfo dir; ///针对当前目录建立目录引用对象 DirectoryInfo dirInfo = new DirectoryInfo(strCurDir); foreach (FileSystemInfo fsi in dirInfo.GetFileSystemInfos()) { if (fsi is FileInfo) { if (fsi.Extension.IndexOf(".xls") < 0) continue; string filename = fsi.FullName; ds1.FileOpen(filename); IList<LP_Temple> templeList = new List<LP_Temple>(); LP_Temple parentTemple = MainHelper.PlatformSqlMap.GetOne<LP_Temple>("where ParentID not in (select LPID from LP_Temple where 1=1 and CtrlSize!='目录') and CellName like '%安规电子档案%'"); if (parentTemple != null) templeList = MainHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList", "where ParentID ='" + parentTemple.LPID + "' order by SortID"); Excel.Worksheet xx = null; Excel.Workbook wb = ds1.AxFramerControl.ActiveDocument as Excel.Workbook; Excel.Worksheet sheet = wb.Application.Sheets[1] as Excel.Worksheet; PJ_ryda currRecord = new PJ_ryda(); currRecord.CreateDate = DateTime.Now; currRecord.BigData = ds1.FileDataGzip; Excel.Range range; WF_TableFieldValue wfv; int i = 0; foreach (LP_Temple lp in templeList) { string[] arrCellPos = lp.CellPos.Split('|'); arrCellPos = StringHelper.ReplaceEmpty(arrCellPos).Split('|'); if (lp.CtrlType.Contains("uc_gridcontrol")) { if (lp.CellName.IndexOf("培训情况") > -1) { for (i = 0; i < 6; i++) { range = sheet.get_Range(sheet.Cells[11 + i, 1], sheet.Cells[11 + i, 1]);//坐标 if (range.Value2 != null && range.Value2.ToString() != "") { wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[0])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[0])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "培训时间1"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); if (wfv.ControlValue != "" && wfv.FieldName.IndexOf("时间") > 0) { wfv.ControlValue = range.Value2.ToString().Replace(".", "-"); DateTime dt = Convert.ToDateTime(wfv.ControlValue); wfv.ControlValue = dt.ToString("yyyy年MM月dd日"); } MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); Thread.Sleep(new TimeSpan(100000));//0.1毫秒 range = sheet.get_Range(sheet.Cells[11 + i, 2], sheet.Cells[11 + i, 2]);//坐标 wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[1])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[1])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "培训类别1"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); } Thread.Sleep(new TimeSpan(100000));//0.1毫秒 range = sheet.get_Range(sheet.Cells[11 + i, 3], sheet.Cells[11 + i, 3]);//坐标 if (range.Value2 != null && range.Value2.ToString() != "") { wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[2])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[2])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "培训时间2"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); if (wfv.ControlValue != "" && wfv.FieldName.IndexOf("时间") > 0) { wfv.ControlValue = range.Value2.ToString().Replace(".", "-"); DateTime dt = Convert.ToDateTime(wfv.ControlValue); wfv.ControlValue = dt.ToString("yyyy年MM月dd日"); } MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); Thread.Sleep(new TimeSpan(100000));//0.1毫秒 range = sheet.get_Range(sheet.Cells[11 + i, 4], sheet.Cells[11 + i, 4]);//坐标 wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[3])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[3])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "培训类别2"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); } } } else if (lp.CellName.IndexOf("考试情况") > -1) { for (i = 0; i < 12; i++) { range = sheet.get_Range(sheet.Cells[19 + i, 1], sheet.Cells[19 + i, 1]);//坐标 if (range.Value2 != null && range.Value2.ToString() != "") { wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[0])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[0])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "考试时间"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); if (wfv.ControlValue != "" && wfv.FieldName.IndexOf("时间") > 0) { wfv.ControlValue = range.Value2.ToString().Replace(".", "-"); DateTime dt = Convert.ToDateTime(wfv.ControlValue); wfv.ControlValue = dt.ToString("yyyy年MM月dd日"); } MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); Thread.Sleep(new TimeSpan(100000));//0.1毫秒 range = sheet.get_Range(sheet.Cells[19 + i, 2], sheet.Cells[19 + i, 2]);//坐标 wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[1])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[1])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "考试类别"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); Thread.Sleep(new TimeSpan(100000));//0.1毫秒 range = sheet.get_Range(sheet.Cells[19 + i, 3], sheet.Cells[19 + i, 3]);//坐标 wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[2])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[2])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "考试成绩"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); Thread.Sleep(new TimeSpan(100000));//0.1毫秒 range = sheet.get_Range(sheet.Cells[19 + i, 4], sheet.Cells[19 + i, 4]);//坐标 wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[3])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[3])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "考试评价"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); Thread.Sleep(new TimeSpan(100000));//0.1毫秒 range = sheet.get_Range(sheet.Cells[19 + i, 5], sheet.Cells[19 + i, 5]);//坐标 wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[4])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[4])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName + "-" + "年检情况"; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); } } } } else { range = sheet.get_Range(sheet.Cells[GetCellPos(arrCellPos[0])[0], GetCellPos(arrCellPos[0])[1]], sheet.Cells[GetCellPos(arrCellPos[0])[0], GetCellPos(arrCellPos[0])[1]]);//坐标 wfv = new WF_TableFieldValue(); wfv.ID = wfv.CreateID(); wfv.RecordId = currRecord.ID; wfv.WorkFlowId = currRecord.ID; wfv.WorkFlowInsId = currRecord.wdmc; wfv.WorkTaskId = "安规电子档案"; wfv.WorkTaskInsId = "安规电子档案"; wfv.UserControlId = parentTemple.LPID; wfv.XExcelPos = GetCellPos(arrCellPos[0])[0]; wfv.YExcelPos = GetCellPos(arrCellPos[0])[1]; wfv.FieldId = lp.LPID; wfv.FieldName = lp.CellName; wfv.ExcelSheetName = lp.KindTable; if (range.Value2 != null) wfv.ControlValue = range.Value2.ToString(); if (wfv.ControlValue != "" && lp.CellName == "出生年月日") { wfv.ControlValue = range.Value2.ToString().Replace(".", "-"); DateTime dt = Convert.ToDateTime(wfv.ControlValue); wfv.ControlValue = dt.ToString("yyyy年MM月dd日"); } if (wfv.ControlValue != "" && lp.CellName == "参加工作时间") { try { wfv.ControlValue = range.Value2.ToString().Replace(".", "-"); DateTime dt = Convert.ToDateTime(wfv.ControlValue); wfv.ControlValue = dt.ToString("yyyy年MM月dd日"); } catch { DateTime dt = new DateTime(Convert.ToInt32(wfv.ControlValue)); wfv.ControlValue = dt.ToString("yyyy年MM月dd日"); } } if (lp.CellName == "姓名") { currRecord.wdmc = wfv.ControlValue; } else if (lp.CellName == "职务") { currRecord.wdlx = wfv.ControlValue; } else if (lp.CellName == "所在单位") { currRecord.OrgName = wfv.ControlValue.Replace(MainHelper.UserCompany, ""); mOrg org = MainHelper.PlatformSqlMap.GetOne<mOrg>("where OrgName='" + currRecord.OrgName + "'"); if (org != null) { currRecord.OrgCode = org.OrgCode; } } wfv.WorkFlowInsId = currRecord.wdmc; MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv); Thread.Sleep(new TimeSpan(100000));//0.1毫秒 } } currRecord.CreateMan = MainHelper.User.UserName; MainHelper.PlatformSqlMap.Create<PJ_ryda>(currRecord); ds1.FileSave(); ds1.FileClose(); } else { dir = (DirectoryInfo)fsi; //获取文件夹路径 GetFileList(ds1, strCurDir + "\\" + dir.Name); } } }
public void InitCtrlData2(RepositoryItemCheckedComboBoxEdit combox, int index, LP_Temple lp, string sqlSentence, DSOFramerControl dsoFramerWordControl1, LP_Record currRecord) { string ctrltype = ""; if (lp.CtrlType.IndexOf(',') == -1) ctrltype = lp.CtrlType; else ctrltype = lp.CtrlType.Substring(0, lp.CtrlType.IndexOf(',')); /* * * SELECT cellname, SqlSentence,SqlColName FROM LP_Temple where SqlSentence !='' * * */ IList li = new ArrayList(); if (sqlSentence.IndexOf("Excel:") == 0) { int index1 = sqlSentence.LastIndexOf(":"); string tablename = sqlSentence.Substring(6, index1 - 6); string cellpos = sqlSentence.Substring(index1 + 1); string[] arrCellPos = cellpos.Split('|'); arrCellPos = StringHelper.ReplaceEmpty(arrCellPos).Split('|'); string strcellvalue = ""; Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; Excel.Worksheet sheet; sheet = wb.Application.Sheets[tablename] as Excel.Worksheet; for (int i = 0; i < arrCellPos.Length; i++) { Excel.Range range = sheet.get_Range(sheet.Cells[GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]], sheet.Cells[GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]]);//坐标 strcellvalue += range.Value2; } li.Add(strcellvalue); } else if (sqlSentence != "") { if (sqlSentence.IndexOf("{recordid}") > -1) { sqlSentence = sqlSentence.Replace("{recordid}", currRecord.ID); } if (sqlSentence.IndexOf("{orgcode}") > -1) { sqlSentence = sqlSentence.Replace("{orgcode}", MainHelper.User.OrgCode); } if (sqlSentence.IndexOf("{userid}") > -1) { sqlSentence = sqlSentence.Replace("{userid}", MainHelper.User.UserID); } Regex r1 = new Regex(@"(?<={)[0-9]+(?=})"); while (r1.Match(sqlSentence).Value != "") { string sortid = r1.Match(sqlSentence).Value; IList<LP_Temple> listLPID = ClientHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList", " where sortID = '" + sortid + "' and parentid = '" + lp.ParentID + "'"); if (listLPID.Count > 0) { string strSQL = "select ControlValue from WF_TableFieldValueView where" + " UserControlId='" + listLPID[0].ParentID + "' " + "and FieldId='" + listLPID[0].LPID + "' and ID='" + currRecord.ID + "'"; li = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL); if (li.Count > 0) { sqlSentence = sqlSentence.Replace("{" + sortid + "}", li[0].ToString()); } else { sqlSentence = sqlSentence.Replace("{" + sortid + "}", "没有找到对应的值,请检查SQL语句设置"); break; } } else { sqlSentence = sqlSentence.Replace("{" + sortid + "}", "没有找到对应的值,请检查SQL语句设置"); break; } } r1 = new Regex(@"(?<={编号规则一:)[0-9]+(?=})"); if (r1.Match(sqlSentence).Value != "") { string sortid = r1.Match(sqlSentence).Value; IList<LP_Temple> listLPID = ClientHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList", " where sortID = '" + sortid + "' and parentid = '" + lp.ParentID + "'"); if (listLPID.Count > 0) { sqlSentence = sqlSentence.Replace("{编号规则一:" + sortid + "}", "出错,没有找到单位控件"); } else { sqlSentence = sqlSentence.Replace("{编号规则一:" + sortid + "}", "出错,没有找到单位控件"); } } sqlSentence = sqlSentence.Replace("\r\n", ""); try { li = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", sqlSentence); } catch (Exception ex) { li.Add(sqlSentence + "出错:" + ex.Message); } if (sqlSentence.IndexOf("where 9=9") == -1) { foreach (string strname in li) { combox.Items.Add(strname); } } else { switch (li[0].ToString()) { case "{年}": combox.Items.Clear(); for (int j = 0; j <= 20; j++) { combox.Items.Add(string.Format("{0}", j + DateTime.Now.Year)); } break; case "{月}": combox.Items.Clear(); for (int j = 1; j <= 12; j++) { combox.Items.Add(string.Format("{0:D2}", j)); } break; case "{日}": combox.Items.Clear(); for (int j = 1; j <= 31; j++) { combox.Items.Add(string.Format("{0:D2}", j)); } break; case "{时}": combox.Items.Clear(); for (int j = 1; j <= 24; j++) { combox.Items.Add(string.Format("{0:D2}", j)); } break; case "{分}": case "{秒}": combox.Items.Clear(); for (int j = 0; j <= 59; j++) { combox.Items.Add(string.Format("{0:D2}", j)); } break; default: string strexpress = li[0].ToString(); r1 = new Regex(@"[0-9]+\+[0-9]+"); if (r1.Match(strexpress).Value != "") { int istart = 1; int ilen = 10; r1 = new Regex(@"[0-9]+(?=\+)"); if (r1.Match(strexpress).Value != "") { istart = Convert.ToInt32(r1.Match(strexpress).Value); } r1 = new Regex(@"(?<=\+)[0-9]+"); if (r1.Match(strexpress).Value != "") { ilen = Convert.ToInt32(r1.Match(strexpress).Value); ; } for (int i = istart; i <= ilen; i++) { combox.Items.Add(string.Format("{0}", i)); } } else { string[] strItem = SelectorHelper.ToDBC(strexpress).Split(','); for (int i = 0; i < strItem.Length; i++) { combox.Items.Add(strItem[i]); } } break; } } } }
public void ExportExcelSubmit(ref LP_Temple parentTemple, string orgid, bool isShow) { DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string fname = Application.StartupPath + "\\00记录模板\\设备标志缺失变更明细表三.xls"; dsoFramerWordControl1.FileOpen(fname); if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent; ExcelAccess ex = new ExcelAccess(); Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; ex.MyWorkBook = wb; ex.MyExcel = wb.Application; string filter = ""; filter = " where 1=1 "; if (orgid != "") filter += " and OrgCode='" + orgid + "'"; if (isWorkflowCall) { filter = filter + " and id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "') " + " or id in (select ModleRecordID from WF_ModleRecordWorkTaskIns where " + " RecordID='" + currRecord.ID + "') " ; } IList<PJ_sbbzqsbgmxb3> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_sbbzqsbgmxb3>( filter ); ExportExcel(ex, datalist, orgid); //ex.ActiveSheet(1); //ex.DeleteWorkSheet(1); //Excel.Worksheet sheet; //for (int i = 1; i <= wb.Application.Sheets.Count; i++) //{ // sheet = wb.Application.Sheets[i] as Excel.Worksheet; // sheet.Cells.Clear(); // sheet.Cells.ClearContents(); // sheet.Cells.ClearOutline(); // sheet.Visible = Excel.XlSheetVisibility.xlSheetHidden; // dsoFramerWordControl1.FileSave(); // break; //} if (parentTemple == null) { parentTemple = new LP_Temple(); parentTemple.Status = "文档生成"; } dsoFramerWordControl1.FileSave(); parentTemple.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); }
public void InitData(string sql, string[] sqlColName, string[] comBoxItem, DSOFramerControl dsoFramerWordControl1, LP_Temple lp, LP_Record currRecord) { //foreach (DevExpress.XtraEditors.Repository.RepositoryItemComboBox combox in colctrllist) for (int i = 0; i < gridView1.Columns.Count; i++) { if (gridView1.Columns[i].ColumnEdit is RepositoryItemComboBox) { RepositoryItemComboBox combox = gridView1.Columns[i].ColumnEdit as RepositoryItemComboBox; combox.Items.Clear(); Regex r1 = new Regex(@"(?<=\[" + i + ":).*?(?=\\])"); string sqlSentence = ""; if (r1.Match(sql).Value != "") { sqlSentence = r1.Match(sql).Value; } if (sqlSentence != "") InitCtrlData(combox, i, lp, sqlSentence, dsoFramerWordControl1, currRecord); } else if (gridView1.Columns[i].ColumnEdit is RepositoryItemCheckedComboBoxEdit) { RepositoryItemCheckedComboBoxEdit combox = gridView1.Columns[i].ColumnEdit as RepositoryItemCheckedComboBoxEdit; combox.Items.Clear(); Regex r1 = new Regex(@"(?<=\[" + i + ":).*?(?=\\])"); string sqlSentence = ""; if (r1.Match(sql).Value != "") { sqlSentence = r1.Match(sql).Value; } if (sqlSentence != "") InitCtrlData2(combox, i, lp, sqlSentence, dsoFramerWordControl1, currRecord); } } }
private void btExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (MainHelper.UserOrg == null) return; if (gridView1.FocusedRowHandle < 0) return; DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname = ""; saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { fname = saveFileDialog1.FileName; try { string slqwhere = " where RecordId='" + dr["recordID"] + "' and UserControlId='" + Temple.LPID + "' and WorkflowId='" + modleGuid + "' and WorkFlowInsId='" + parentObj.OrgName + "' "; IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>(slqwhere); DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); dsoFramerWordControl1.FileDataGzip = Temple.DocContent; Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; Excel.Worksheet xx; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; string activeSheetName = ""; xx = wb.Application.Sheets[1] as Excel.Worksheet; int i = 0; ArrayList al = new ArrayList(); for (i = 1; i <= wb.Application.Sheets.Count; i++) { xx = wb.Application.Sheets[i] as Excel.Worksheet; if (!al.Contains(xx.Name)) al.Add(xx.Name); } for (i = 0; i < tfvli.Count; i++) { if (!al.Contains(tfvli[i].ExcelSheetName)) { continue; } LP_Temple field = MainHelper.PlatformSqlMap.GetOneByKey<LP_Temple>(tfvli[i].FieldId); if (field != null) { if (field.isExplorer == 1) { continue; } } if (activeSheetName != tfvli[i].ExcelSheetName) { if (activeSheetName != "") { xx = wb.Application.Sheets[activeSheetName] as Excel.Worksheet; } xx = wb.Application.Sheets[tfvli[i].ExcelSheetName] as Excel.Worksheet; activeSheetName = tfvli[i].ExcelSheetName; ea.ActiveSheet(xx.Index); } if (tfvli[i].XExcelPos > -1 && tfvli[i].YExcelPos > -1) ea.SetCellValue(tfvli[i].ControlValue, tfvli[i].XExcelPos, tfvli[i].YExcelPos); } dsoFramerWordControl1.FileDataGzip = Temple.DocContent; dsoFramerWordControl1.FileSave(fname, true); dsoFramerWordControl1.FileClose(); if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) return; System.Diagnostics.Process.Start(fname); } catch (Exception ex) { Console.WriteLine(ex.Message); MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。"); return; } } }
public static void ExportExcelWorkFlow(ref LP_Record currRecord, PJ_03yxfx obj) { DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl(); string fname = Application.StartupPath + "\\00记录模板\\03运行分析记录.xls"; dsoFramerWordControl1.FileOpen(fname); if (currRecord == null) { currRecord = new LP_Record(); currRecord.Status = "文档生成"; } currRecord.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); dsoFramerWordControl1.FileDataGzip = currRecord.DocContent; ExcelAccess ex = new ExcelAccess(); Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; ex.MyWorkBook = wb; ex.MyExcel = wb.Application; //与会人员之间的间隔符号 string jksign = "@"; int row = 1; int col = 1; //每行显示文字长度 int zc = 60; //获得创建的工作表个数 // int pagemax = 1; string zt = Ecommon.Comparestring(obj.zt, "主题") ? "" : "主题:"; List<string> listztstring = Ecommon.ResultStrList(zt + obj.zt, zc); Ecommon.Resultstrbystartbd(ref listztstring); //if (pagemax < Ecommon.GetPagecount(listztstring.Count,2)) //{ // pagemax = Ecommon.GetPagecount(listztstring.Count, 2); //} string jy = Ecommon.Comparestring(obj.jy, "纪要") ? "" : "纪要:"; List<string> listjy = Ecommon.ResultStrList(jy + obj.jy, zc); Ecommon.Resultstrbystartbd(ref listjy); //if (pagemax < Ecommon.GetPagecount(listjy.Count, 7)) //{ // pagemax = Ecommon.GetPagecount(listjy.Count, 7); //} string jr = Ecommon.Comparestring(obj.jr, "结论及对策") ? "" : "结论及对策:"; List<string> listjldc = Ecommon.ResultStrList(jr + obj.jr, zc); Ecommon.Resultstrbystartbd(ref listjldc); //if (pagemax < Ecommon.GetPagecount(listjldc.Count, 6)) //{ // pagemax = Ecommon.GetPagecount(listjldc.Count, 6); //} List<string> listpy = Ecommon.ResultStrList("领导检查评语:" + obj.py, zc); Ecommon.Resultstrbystartbd(ref listpy); int[] strnumcol = { 0, listztstring.Count, listztstring.Count + listjy.Count, listztstring.Count + listjy.Count + listjldc.Count }; int[] statnum = { 3, 3, 6,7 }; List<string> strcol = new List<string>(); Ecommon.addstring(listztstring, ref strcol); Ecommon.addstring(listjy, ref strcol); Ecommon.addstring(listjldc, ref strcol); Ecommon.addstring(listpy, ref strcol); //Ecommon.CreatandWritesheet(ex, strcol, 15, 9, 1); Ecommon.CreatandWritesheet1(ex, strcol, 15, 9, 1, strnumcol, statnum); //进行加粗 ex.ActiveSheet(1); //时间 ex.SetCellValue(obj.rq.Year.ToString(), 4, 5); ex.SetCellValue(obj.rq.Month.ToString(), 4, 7); ex.SetCellValue(obj.rq.Day.ToString(), 4, 9); ////出席人员 string[] ary = obj.cjry.Split(';'); int n = ary.Length % 5; for (int i = 0; i < ary.Length; i++) { int tempcol = col + 1 + i % 5; if (i % 5 == 1 || i % 5 == 2 || i % 5 == 3) { tempcol = col + 1 + i % 5 + 1; } if (i % 5 == 4) { tempcol = col + 1 + i % 5 + 2; } ex.SetCellValue(ary[i], row + 4 + i / 5, tempcol); } //主持人 ex.SetCellValue(obj.zcr, 5, 11); //检查人签字 //ex.CopySheet(1, 2); //ex.ActiveSheet(2); //ex.SetCellValue("kakaka", 24, 4); //ex.ActiveSheet(1); ex.SetCellValue(obj.qz, 24, 4); //签字时间 // if (ComboBoxHelper.CompreDate(obj.qzrq)) // { // ex.SetCellValue(obj.qzrq.Year.ToString(), 24, 5); // ex.SetCellValue(obj.qzrq.Month.ToString(), 24, 9); // ex.SetCellValue(obj.qzrq.Day.ToString(), 24, 11); // } //将固定的写完再创建不固定的。 //添加变动内容 //for (int j = 1; j <= pagemax;j++ ) //{ // if (j>1) // { // ex.CopySheet(1, 1); // } //} //ex.ShowExcel(); //for (int j = 1; j <= pagemax;j++ ) //{ // ex.ActiveSheet(j); // //if (j>1) // //{ // // // ex.CopySheet(1, j); // // ex.ActiveSheet(j); // //} // //ex.ShowExcel(); // int prepageindex = j - 1; // //主题 // int starow = prepageindex * 2 + 1; // int endrow = j * 2; // if (listztstring.Count>endrow) // { // for (int i = 0; i < 2;i++ ) // { // ex.SetCellValue(listztstring[starow - 1 + i], 9 + i, 1); // } // } // else if (listztstring.Count<=endrow&&listztstring.Count>=starow) // { // for (int i = 0; i < listztstring.Count - starow + 1;i++ ) // { // ex.SetCellValue(listztstring[starow - 1 + i], 9 + i, 1); // } // } // //纪要 // starow = prepageindex * 7 + 1; // endrow = j * 7; // if (listjy.Count > endrow) // { // for (int i = 0; i < 7; i++) // { // ex.SetCellValue(listjy[starow - 1 + i], 11 + i, 1); // } // } // else if (listjy.Count <= endrow && listjy.Count >= starow) // { // for (int i = 0; i < listjy.Count - starow + 1; i++) // { // ex.SetCellValue(listjy[starow - 1 + i], 11+ i, 1); // } // } // //结论及对策 // starow = prepageindex * 6 + 1; // endrow = j * 6; // if (listjldc.Count > endrow) // { // for (int i = 0; i < 6; i++) // { // ex.SetCellValue(listjldc[starow - 1 + i], 18 + i, 1); // } // } // else if (listjldc.Count <= endrow && listjldc.Count >= starow) // { // for (int i = 0; i < listjldc.Count - starow + 1; i++) // { // ex.SetCellValue(listjldc[starow - 1 + i], 18 + i, 1); // } // } //} ////主题: //ex.SetCellValue("主题: " + obj.zt, 9, 1); ////纪要 //string jystr = "纪要:" + obj.jy; //for (int i = 0; i < 7; i++) //{ // string tempstr = ""; // int startnum = i * zc; // int endnum = (i + 1) * zc; // bool ISempty=false; // if (startnum>=jystr.Length) // { // ISempty=true; // } // else if (endnum >= jystr.Length) // { // endnum = jystr.Length; // } // if (!ISempty) // { // tempstr = jystr.Substring(startnum,endnum-startnum); // } // ex.SetCellValue(tempstr, 11 + i, 1); //} ////结论及对策: //string jlstr = "结论及对策:" + obj.jr; //for (int j = 0; j < 6; j++) //{ // string tempstr = ""; // int startnum = j * zc; // int endnum = (j + 1) * zc; // bool ISempty = false; // if (startnum >= jlstr.Length) // { // ISempty = true; // } // else if (endnum >= jlstr.Length) // { // endnum = jlstr.Length; // } // if (!ISempty) // { // tempstr = jlstr.Substring(startnum, endnum - startnum); // } // ex.SetCellValue(tempstr, 18 + j, 1); //} //ex.CopySheet(1,2); //ex.CopySheet(1, 3); //ex.CopySheet(2, 4); if (currRecord == null) { currRecord = new LP_Record(); currRecord.Status = "文档生成"; } dsoFramerWordControl1.FileSave(); currRecord.DocContent = dsoFramerWordControl1.FileDataGzip; dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); }
private void btView_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridView1.FocusedRowHandle > -1) { PJ_24 OBJECT = gridView1.GetRow(gridView1.FocusedRowHandle) as PJ_24; if (OBJECT.BigData != null) { if (OBJECT.BigData.Length != 0) { DSOFramerControl ds1 = new DSOFramerControl(); ds1.FileData = OBJECT.BigData; string fname = ds1.FileName; ds1.FileClose(); // ds1.FileOpen(ds1.FileName); ExcelAccess ex = new ExcelAccess(); ex.Open(fname); //此处写填充内容代码 ex.ShowExcel(); } else { Export24.ExportExcel(OBJECT); } } else { Export24.ExportExcel(OBJECT); } } }
public static void iniTableRecordData(ref LP_Temple temple, DSOFramerControl dsoFramerWordControl1, LP_Record currRecord, string WorkflowId, string WorkFlowInsId, bool isExplorerCall) { if (temple != null) { if (dsoFramerWordControl1 == null) dsoFramerWordControl1 = new DSOFramerControl(); try { if (isExplorerCall) { string strkind = currRecord.Kind; if (strkind == "dzczp") strkind = "电力线路倒闸操作票"; else if (strkind == "yzgzp") strkind = "电力线路第一种工作票"; else if (strkind == "ezgzp") strkind = "电力线路第二种工作票"; else if (strkind == "xlqxp") strkind = "电力线路事故应急抢修单"; if (currRecord.DocContent != null && currRecord.DocContent.Length > 0 && strkind.IndexOf("电力线路") > -1) dsoFramerWordControl1.FileDataGzip = currRecord.DocContent; else dsoFramerWordControl1.FileDataGzip = temple.DocContent; } else dsoFramerWordControl1.FileDataGzip = temple.DocContent; WF_WorkFlow wf = MainHelper.PlatformSqlMap.GetOneByKey<WF_WorkFlow>(WorkflowId); //IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList", // " where RecordId='" + currRecord.ID + "' and UserControlId='" + temple.LPID + "' and WorkflowId='" + WorkflowId + "' and WorkFlowInsId='" + WorkFlowInsId + "' "); IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList", " where RecordId='" + currRecord.ID + "' and UserControlId='" + temple.LPID + "' and WorkflowId='" + WorkflowId + "' and WorkFlowInsId='" + WorkFlowInsId + "' "); Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; Excel.Worksheet xx; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; string activeSheetName = ""; xx = wb.Application.Sheets[1] as Excel.Worksheet; int i = 0; ArrayList al = new ArrayList(); for (i = 1; i <= wb.Application.Sheets.Count; i++) { xx = wb.Application.Sheets[i] as Excel.Worksheet; if (!al.Contains(xx.Name)) al.Add(xx.Name); } for (i = 0; i < tfvli.Count; i++) { if (!al.Contains(tfvli[i].ExcelSheetName)) { continue; } if (isExplorerCall) { if (!HaveRunPowerRole(WorkConst.WorkTask_FlowEndExplore, tfvli[i].WorkFlowId, tfvli[i].WorkFlowId) || (currRecord.Status != "存档")) { //if (!RecordWorkTask.HaveWorkFlowAllExploreRole(tfvli[i].WorkTaskId, tfvli[i].WorkFlowId)) { //if (!RecordWorkTask.HaveWorkFlowExploreRole(tfvli[i].WorkTaskId, tfvli[i].WorkFlowId)) { continue; } } } } if (activeSheetName != tfvli[i].ExcelSheetName) { if (activeSheetName != "") { xx = wb.Application.Sheets[activeSheetName] as Excel.Worksheet; } xx = wb.Application.Sheets[tfvli[i].ExcelSheetName] as Excel.Worksheet; activeSheetName = tfvli[i].ExcelSheetName; ea.ActiveSheet(xx.Index); } LP_Temple field = MainHelper.PlatformSqlMap.GetOneByKey<LP_Temple>(tfvli[i].FieldId); if (field != null) { if (field.isExplorer == 1) { unLockExcel(wb, xx); ea.SetCellValue("", tfvli[i].XExcelPos, tfvli[i].YExcelPos); LockExcel(wb, xx); //LockExcel(wb, xx); //continue; } } //if (tfvli[i].XExcelPos > -1 && tfvli[i].YExcelPos > -1) //{ // if (tfvli[i].FieldName!="编号") // ea.SetCellValue(tfvli[i].ControlValue, tfvli[i].XExcelPos, tfvli[i].YExcelPos); // else // ea.SetCellValue("'"+tfvli[i].ControlValue, tfvli[i].XExcelPos, tfvli[i].YExcelPos); //} } dsoFramerWordControl1.FileSave(); temple.DocContent = dsoFramerWordControl1.FileDataGzip; } catch (Exception ex) { Console.WriteLine(ex.Message); } dsoFramerWordControl1.FileSave(); dsoFramerWordControl1.FileClose(); } }