Ejemplo n.º 1
0
        private void AddExportXSD(string pdeFilePath, string stnName, PdeExports exportData)
        {
            Excel.Application app = new Excel.Application();
            app.Visible = false;
            Excel.Workbook workbook = app.Workbooks.Open(pdeFilePath);

            try
            {
                Excel.XmlMaps maps = workbook.XmlMaps;

                // delete old mapp
                DeleteOldMap(maps, ProntoDoc.Framework.CoreObject.FrameworkConstants.PdeExportedMapName);

                // gen new xsd
                string xsdFile = GenExportedXSD(stnName, exportData);

                // add new map
                Excel.XmlMap map = maps.Add(xsdFile);
                map.Name = ProntoDoc.Framework.CoreObject.FrameworkConstants.PdeExportedMapName;

                // save
                workbook.Save();

                // delete xsd file
                ProntoDoc.Framework.Utils.FileHelper.DeleteFile(xsdFile);
            }
            finally
            {
                ((Excel._Workbook)workbook).Close();
                ((Excel._Application)app).Quit();
            }
        }
Ejemplo n.º 2
0
 private void DeleteOldMap(Excel.XmlMaps maps, string name)
 {
     foreach (Excel.XmlMap map in maps)
     {
         if (string.Equals(name, map.Name))
         {
             map.Delete();
             break;
         }
     }
 }