private bool addWordItem(String subTemplateName, ExportItemMap itemMap) { word.Application Word = Globals.ThisAddIn.wordApp; if (Word == null || Word.Visible == false) { MessageBox.Show("word doesn't link, this just for debug"); return(false);//do not link, just return. } COMAddIns addins = Word.COMAddIns; foreach (COMAddIn addin in addins) { if (addin.Description.Equals("Pdw")) { Object pdwApp = addin.Object; //object[] invokeArgs = { subTemplateName, itemMap.treeNodeIndex, itemMap.treeNodeName, itemMap.type }; int[] indexs; string[] names; string[] types; if (itemMap.mapType == ProntoDoc.Framework.CoreObject.MapType.singleCell) { indexs = new int[1]; names = new string[1]; types = new string[1]; } else { int count = itemMap.tabCols.Count + 1; indexs = new int[count]; names = new string[count]; types = new string[count]; int i = 1; foreach (TableColumnMap col in itemMap.tabCols) { indexs[i] = 0;// names[i] = col.treeNodeName; types[i] = col.dataType; i++; } } indexs[0] = itemMap.treeNodeIndex; names[0] = itemMap.treeNodeName; types[0] = itemMap.dataType; object[] invokeArgs = { subTemplateName, indexs, names, types }; try { object retVal = pdwApp.GetType().InvokeMember("addPdeItem", System.Reflection.BindingFlags.InvokeMethod, null, pdwApp, invokeArgs); return(Boolean.Parse(retVal.ToString())); } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } } } return(false); }
public Boolean exportItem(Workbook workbook, ProntoExcelMarkup proMarkupCtrl) { //make sure current selection is cell. Range curCell = workbook.Application.ActiveCell; curCell.Select(); string excelName = GetNameForRange(workbook.Application); if (checkDuplicate(excelName)) { MessageBox.Show("This cell already exported."); return(false); } string type = getDataType(curCell); TreeNode node = proMarkupCtrl.treeView2.Nodes[0].Nodes.Add(excelName); ExportItemMap itemMap = new ExportItemMap(); itemMap.mapType = ProntoDoc.Framework.CoreObject.MapType.singleCell; itemMap.excelName = excelName; itemMap.treeNodeName = excelName; //default value is excle range name; itemMap.treeNodeIndex = node.Index; itemMap.dataType = type; itemMap.treeNodePath = node.FullPath; exportItems.Add(itemMap); //hightlight the cell highlightRange(curCell); //refresh word tree automatic. string fullName = workbook.FullName; String subTemplateName = null; Globals.ThisAddIn.subTempMaps.TryGetValue(fullName, out subTemplateName); addWordItem(subTemplateName, itemMap); return(true); }
public bool exportTable(Workbook workbook, ProntoExcelMarkup proMarkupCtrl) { //check whether current selection is table. Worksheet curSheet = workbook.ActiveSheet; Range actCell = workbook.Application.ActiveCell; ListObject lst = null; try { lst = actCell.ListObject; } catch { } if (lst == null) { MessageBox.Show("Please select a table in excel"); return(false); } //show window to select and define business tag. ExpTableForm expFrm = new ExpTableForm(); expFrm.initDataSource(lst.ListColumns); expFrm.ShowDialog(); List <TableColumnMap> cols = expFrm.cols; //expFrm.Close(); if (cols == null || cols.Count < 1) { return(false); } //update tree TreeNode node = proMarkupCtrl.treeView2.Nodes[0].Nodes.Add(lst.Name); foreach (TableColumnMap col in cols) { node.Nodes.Add(col.treeNodeName); //highlight exported column in table Range r = lst.ListColumns.get_Item(col.columnName).Range; highlightRange(r); } //save mapinformation ExportItemMap item = new ExportItemMap(); item.excelName = workbook.ActiveSheet.Name + "!" + lst.Name; item.mapType = ProntoDoc.Framework.CoreObject.MapType.Table; item.treeNodeName = node.Text; item.treeNodePath = node.FullPath; item.treeNodeIndex = node.Index; item.tabCols = cols; exportItems.Add(item); //update the tree in word. string fullName = workbook.FullName; String subTemplateName = null; Globals.ThisAddIn.subTempMaps.TryGetValue(fullName, out subTemplateName); addWordItem(subTemplateName, item); return(true); }