当前位置: 首页>>代码示例>>C#>>正文


C# OPC.PackagePart类代码示例

本文整理汇总了C#中NPOI.OpenXml4Net.OPC.PackagePart的典型用法代码示例。如果您正苦于以下问题:C# PackagePart类的具体用法?C# PackagePart怎么用?C# PackagePart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PackagePart类属于NPOI.OpenXml4Net.OPC命名空间,在下文中一共展示了PackagePart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommentsTable

        internal CommentsTable(PackagePart part, PackageRelationship rel)
            : base(part, rel)
        {

            XmlDocument xml = ConvertStreamToXml(part.GetInputStream());
            ReadFrom(xml);
        }
开发者ID:89sos98,项目名称:npoi,代码行数:7,代码来源:CommentsTable.cs

示例2: CreateDocumentPart

        public override POIXMLDocumentPart CreateDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part)
        {
            POIXMLRelation descriptor = XWPFRelation.GetInstance(rel.RelationshipType);
            if (descriptor == null || descriptor.RelationClass == null)
            {
                logger.Log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.RelationshipType);
                return new POIXMLDocumentPart(part, rel);
            }

            try
            {
                Type cls = descriptor.RelationClass;
                try
                {
                    ConstructorInfo constructor = cls.GetConstructor(new Type[] { typeof(POIXMLDocumentPart), typeof(PackagePart), typeof(PackageRelationship) });
                    return constructor.Invoke(new object[] { parent, part, rel }) as POIXMLDocumentPart;
                }
                catch (Exception)
                {
                    ConstructorInfo constructor = cls.GetConstructor(new Type[] { typeof(PackagePart), typeof(PackageRelationship) });
                    return constructor.Invoke(new object[] { part, rel }) as POIXMLDocumentPart;
                }
            }
            catch (Exception e)
            {
                throw new POIXMLException(e);
            }
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:28,代码来源:XWPFFactory.cs

示例3: XSSFChart

        /**
         * Construct a SpreadsheetML chart from a namespace part.
         *
         * @param part the namespace part holding the chart data,
         * the content type must be <code>application/vnd.Openxmlformats-officedocument.Drawingml.chart+xml</code>
         * @param rel  the namespace relationship holding this chart,
         * the relationship type must be http://schemas.Openxmlformats.org/officeDocument/2006/relationships/chart
         */
        protected XSSFChart(PackagePart part, PackageRelationship rel)
            : base(part, rel)
        {

            XmlDocument doc = ConvertStreamToXml(part.GetInputStream());
            chartSpaceDocument = ChartSpaceDocument.Parse(doc, NamespaceManager);
            chart = chartSpaceDocument.GetChartSpace().chart;
        }
开发者ID:eatage,项目名称:npoi,代码行数:16,代码来源:XSSFChart.cs

示例4: XSSFChart

        /**
         * Construct a SpreadsheetML chart from a namespace part.
         *
         * @param part the namespace part holding the chart data,
         * the content type must be <code>application/vnd.Openxmlformats-officedocument.Drawingml.chart+xml</code>
         * @param rel  the namespace relationship holding this chart,
         * the relationship type must be http://schemas.Openxmlformats.org/officeDocument/2006/relationships/chart
         */
        protected XSSFChart(PackagePart part, PackageRelationship rel)
            : base(part, rel)
        {


            chartSpace = ChartSpaceDocument.Parse(part.GetInputStream()).GetChartSpace();
            chart = chartSpace.chart;
        }
开发者ID:WPG,项目名称:npoi,代码行数:16,代码来源:XSSFChart.cs

示例5: XSSFDrawing

 /**
  * Construct a SpreadsheetML Drawing from a namespace part
  *
  * @param part the namespace part holding the Drawing data,
  * the content type must be <code>application/vnd.openxmlformats-officedocument.Drawing+xml</code>
  * @param rel  the namespace relationship holding this Drawing,
  * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing
  */
 internal XSSFDrawing(PackagePart part, PackageRelationship rel)
     : base(part, rel)
 {
     //XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
     ////Removing root element
     //options.setLoadReplaceDocumentElement(null);
     //drawing = CTDrawing.Factory.parse(part.getInputStream(), options);
     drawing = NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_Drawing.Parse(part.GetInputStream());
 }
开发者ID:kenlen,项目名称:npoi,代码行数:17,代码来源:XSSFDrawing.cs

示例6: Marshall

        /**
         * Save the specified part.
         *
         * @throws OpenXml4NetException
         *             Throws if an internal exception is thrown.
         */
        public bool Marshall(PackagePart part, Stream os)
        {
            if (!(os is ZipOutputStream))
            {
                logger.Log(POILogger.ERROR,"Unexpected class " + os.GetType().Name);
                throw new OpenXml4NetException("ZipOutputStream expected !");
                // Normally should happen only in developement phase, so just throw
                // exception
            }

            ZipOutputStream zos = (ZipOutputStream)os;
            string name = ZipHelper
                    .GetZipItemNameFromOPCName(part.PartName.URI
                            .OriginalString);
            ZipEntry partEntry = new ZipEntry(name);
            try
            {
                // Create next zip entry
                zos.PutNextEntry(partEntry);

                // Saving data in the ZIP file
                Stream ins = part.GetInputStream();
                byte[] buff = new byte[ZipHelper.READ_WRITE_FILE_BUFFER_SIZE];
                int totalRead = 0;
                while (true)
                {
                    int resultRead = ins.Read(buff, 0, buff.Length);
                    if (resultRead == 0)
                    {
                        // End of file reached
                        break;
                    }
                    zos.Write(buff, 0, resultRead);
                    totalRead += resultRead;
                }
                zos.CloseEntry();
            }
            catch (IOException ioe)
            {
                logger.Log(POILogger.ERROR, "Cannot write: " + part.PartName + ": in ZIP", ioe);
                return false;
            }

            // Saving relationship part
            if (part.HasRelationships)
            {
                PackagePartName relationshipPartName = PackagingUriHelper
                        .GetRelationshipPartName(part.PartName);

                MarshallRelationshipPart(part.Relationships,
                        relationshipPartName, zos);

            }
            return true;
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:61,代码来源:ZipPartMarshaller.cs

示例7: XWPFHeaderFooter

        public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel) :
            base(parent, part, rel)
        {
            ;
            this.document = (XWPFDocument)GetParent();

            if (this.document == null)
            {
                throw new NullReferenceException();
            }
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:11,代码来源:XWPFHeaderFooter.cs

示例8: ThemesTable

        internal ThemesTable(PackagePart part, PackageRelationship rel)
            : base(part, rel)
        {

            //theme = ThemeDocument.Parse(part.GetInputStream());
            try
            {
                theme = ThemeDocument.Parse(part.GetInputStream());
            }
            catch (XmlException e)
            {
                throw new IOException(e.Message);
            }
        }
开发者ID:WPG,项目名称:npoi,代码行数:14,代码来源:ThemesTable.cs

示例9: ThemesTable

        /**
         * Construct a ThemesTable.
         * @param part A PackagePart.
         * @param rel A PackageRelationship.
         */
        internal ThemesTable(PackagePart part, PackageRelationship rel)
            : base(part, rel)
        {

            XmlDocument xmldoc = ConvertStreamToXml(part.GetInputStream());
                
            try
            {
                theme = ThemeDocument.Parse(xmldoc, NamespaceManager);
            }
            catch (XmlException e)
            {
                throw new IOException(e.Message);
            }
        }
开发者ID:twxstar,项目名称:npoi,代码行数:20,代码来源:ThemesTable.cs

示例10: PackageRelationship

        /**
         * Constructor.
         * 
         * @param pkg
         * @param sourcePart
         * @param targetUri
         * @param targetMode
         * @param relationshipType
         * @param id
         */
        public PackageRelationship(OPCPackage pkg, PackagePart sourcePart,
                Uri targetUri, TargetMode targetMode, String relationshipType,
                String id)
        {
            if (pkg == null)
                throw new ArgumentException("pkg");
            if (targetUri == null)
                throw new ArgumentException("targetUri");
            if (relationshipType == null)
                throw new ArgumentException("relationshipType");
            if (id == null)
                throw new ArgumentException("id");

            this.container = pkg;
            this.source = sourcePart;
            this.targetUri = targetUri;
            this.targetMode = targetMode;
            this.relationshipType = relationshipType;
            this.id = id;
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:30,代码来源:PackageRelationship.cs

示例11: GetImageDimension

 /**
  * Return the dimension of this image
  *
  * @param part the namespace part holding raw picture data
  * @param type type of the picture: {@link Workbook#PICTURE_TYPE_JPEG},
  * {@link Workbook#PICTURE_TYPE_PNG} or {@link Workbook#PICTURE_TYPE_DIB}
  *
  * @return image dimension in pixels
  */
 protected static Size GetImageDimension(PackagePart part, int type)
 {
     try
     {
         return Image.FromStream(part.GetInputStream()).Size;
     }
     catch (IOException e)
     {
         //return a "singulariry" if ImageIO failed to read the image
         logger.Log(POILogger.WARN, e);
         return new Size();
     }
 }
开发者ID:hanwangkun,项目名称:npoi,代码行数:22,代码来源:XSSFPicture.cs

示例12: GetImageDimension

 /**
  * Return the dimension of this image
  *
  * @param part the namespace part holding raw picture data
  * @param type type of the picture: {@link Workbook#PICTURE_TYPE_JPEG},
  * {@link Workbook#PICTURE_TYPE_PNG} or {@link Workbook#PICTURE_TYPE_DIB}
  *
  * @return image dimension in pixels
  */
 protected static Size GetImageDimension(PackagePart part, PictureType type)
 {
     try
     {
         //return Image.FromStream(part.GetInputStream()).Size;
         //java can only read png,jpeg,dib image
         //C# read the image that format defined by PictureType , maybe.
         return ImageUtils.GetImageDimension(part.GetInputStream());
     }
     catch (IOException e)
     {
         //return a "singulariry" if ImageIO failed to read the image
         logger.Log(POILogger.WARN, e);
         return new Size();
     }
 }
开发者ID:newlysoft,项目名称:npoi,代码行数:25,代码来源:XSSFPicture.cs

示例13: XWPFPictureData

 /**
  * Construct XWPFPictureData from a package part
  *
  * @param part the package part holding the Drawing data,
  * @param rel  the package relationship holding this Drawing,
  * the relationship type must be http://schemas.Openxmlformats.org/officeDocument/2006/relationships/image
  */
 public XWPFPictureData(PackagePart part, PackageRelationship rel)
     : base(part, rel)
 {
 }
开发者ID:xiepeixing,项目名称:npoi,代码行数:11,代码来源:XWPFPictureData.cs

示例14: CreatePartName

 /**
  * Create an OPC compliant part name by resolving it using a base part.
  *
  * @param partName
  *            The part name Uri to validate.
  * @param relativePart
  *            The relative base part.
  * @return The correspondant part name if valid, else <code>null</code>.
  * @throws InvalidFormatException
  *             Throws if the specified part name is not OPC compliant.
  * @see #CreatePartName(Uri)
  */
 public static PackagePartName CreatePartName(Uri partName,
         PackagePart relativePart)
 {
     Uri newPartNameURI = ResolvePartUri(
             relativePart.PartName.URI, partName);
     return CreatePartName(newPartNameURI);
 }
开发者ID:WPG,项目名称:npoi,代码行数:19,代码来源:PackagingUriHelper.cs

示例15: MapInfo

        internal MapInfo(PackagePart part, PackageRelationship rel)
            : base(part, rel)
        {

            ReadFrom(part.GetInputStream());
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:6,代码来源:MapInfo.cs


注:本文中的NPOI.OpenXml4Net.OPC.PackagePart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。