Ejemplo n.º 1
0
        public static CT_Types GetContentTypes(XFile rootFile, MemoryFolder mFolder, ExcelFileType workbookType)
        {
            if (((rootFile == null) || (rootFile.RelationFiles == null)) || ((rootFile.RelationFiles.Count == 0) || (mFolder == null)))
            {
                return(null);
            }
            List <object> defaultType = GetDefaultType();

            if (defaultType == null)
            {
                return(null);
            }
            if (!UpdateFileList(defaultType, rootFile, mFolder, workbookType))
            {
                return(null);
            }
            return(new CT_Types {
                Items = defaultType.ToArray()
            });
        }
Ejemplo n.º 2
0
 private static void SavePackageRelationFiles(XFile xFile, MemoryFolder mFolder)
 {
     if (((xFile != null) && (xFile.RelationFiles != null)) && ((xFile.RelationFiles.Count != 0) && (mFolder != null)))
     {
         string str  = string.IsNullOrEmpty(xFile.FileName) ? "" : Path.GetDirectoryName(xFile.FileName);
         string str2 = string.IsNullOrEmpty(xFile.FileName) ? "" : Path.GetFileName(xFile.FileName);
         Dictionary <string, string[]> htRelationShip = new Dictionary <string, string[]>();
         foreach (string str3 in xFile.RelationFiles.Keys)
         {
             XFile file = xFile.RelationFiles[str3];
             if (file != null)
             {
                 string[] strArray = new string[2];
                 if (!string.IsNullOrWhiteSpace(file.Target))
                 {
                     strArray[0] = file.Target;
                 }
                 else
                 {
                     strArray[0] = file.FileName.Replace('\\', '/');
                 }
                 strArray[1] = file.FileType;
                 if (htRelationShip.ContainsKey(str3))
                 {
                     htRelationShip[str3] = strArray;
                 }
                 else
                 {
                     htRelationShip.Add(str3, strArray);
                 }
             }
             SavePackageRelationFiles(file, mFolder);
         }
         CT_Relationships relationships = ToRelationships(htRelationShip);
         if (relationships != null)
         {
             mFolder.CreateMemoryFile(str + @"\_rels\" + str2 + ".rels", PackageXml.CreateStreamFromObject(relationships, typeof(CT_Relationships)));
         }
     }
 }