• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DocumentFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SetCellDate

        public static void SetCellDate(WorksheetPart worksheetPart, DateTime value, string columnName, DocumentFormat.OpenXml.Spreadsheet.Row row)
        {
            Cell cell = GetCell(worksheetPart.Worksheet, columnName, row);

            cell.CellValue = new CellValue(value.ToOADate().ToString("0"));
            cell.DataType = new EnumValue<CellValues>(CellValues.Number);
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:7,代码来源:ExcelTools.cs


示例2: Start

        public void Start(Int32 pollingTimeInMs)
        {
            var jobDataMap = context.JobDetail.JobDataMap;
            PipelineId = new PipelineId(jobDataMap.GetString(JobKeys.PipelineId));

            InputDocumentId = new DocumentId(jobDataMap.GetString(JobKeys.DocumentId));
            InputBlobId = new BlobId(jobDataMap.GetString(JobKeys.BlobId));
            InputDocumentFormat = new DocumentFormat(jobDataMap.GetString(JobKeys.Format));

            if (TenantId == null)
                throw new Exception("tenant not set!");

            _workingFolder = Path.Combine(
                ConfigService.GetWorkingFolder(TenantId, InputBlobId),
                GetType().Name
            );

            OnExecute(context);

            try
            {
                if (Directory.Exists(_workingFolder))
                    Directory.Delete(_workingFolder, true);
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat(ex, "Error deleting {0}", _workingFolder);
            }

            pollingTimer = new Timer(pollingTimeInMs);
            pollingTimer.Elapsed += pollingTimer_Elapsed;
            pollingTimer.Start();
        }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:33,代码来源:AbstractPollerFileJob.cs


示例3: DeleteFormatFromDocumentDescriptor

 public DeleteFormatFromDocumentDescriptor(
     DocumentDescriptorId aggregateId, 
     DocumentFormat documentFormat) : base(aggregateId)
 {
     if (aggregateId == null) throw new ArgumentNullException("aggregateId");
     DocumentFormat = documentFormat;
 }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:7,代码来源:DeleteFormatFromDocumentDescriptor.cs


示例4: SetCell

        public static void SetCell(WorksheetPart worksheetPart, string text, string columnName, DocumentFormat.OpenXml.Spreadsheet.Row row, out Cell cell)
        {
            cell = GetCell(worksheetPart.Worksheet, columnName, row);

            cell.CellValue = new CellValue(string.IsNullOrWhiteSpace(text) ? "" : text);
            cell.DataType = new EnumValue<CellValues>(CellValues.String);
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:7,代码来源:ExcelTools.cs


示例5: StreamToFile

        /// <summary>
        /// Stream to file
        /// </summary>
        /// <param name="inputStream"></param>
        /// <param name="outputFile"></param>
        /// <param name="fileMode"></param>
        /// <param name="sourceRectangle"></param>
        /// <returns></returns>
        public static string StreamToFile(Stream inputStream, string outputFile, FileMode fileMode, DocumentFormat.OpenXml.Drawing.SourceRectangle sourceRectangle)
        {
            try
            {
                if (inputStream == null)
                    throw new ArgumentNullException("inputStream");

                if (String.IsNullOrEmpty(outputFile))
                    throw new ArgumentException("Argument null or empty.", "outputFile");

                if (Path.GetExtension(outputFile).ToLower() == ".emf" || Path.GetExtension(outputFile).ToLower() == ".wmf")
                {
                    System.Drawing.Imaging.Metafile emf = new System.Drawing.Imaging.Metafile(inputStream);
                    System.Drawing.Rectangle cropRectangle;

                    double leftPercentage = (sourceRectangle != null && sourceRectangle.Left != null) ? ToPercentage(sourceRectangle.Left.Value) : 0;
                    double topPercentage = (sourceRectangle != null && sourceRectangle.Top != null) ? ToPercentage(sourceRectangle.Top.Value) : 0;
                    double rightPercentage = (sourceRectangle != null && sourceRectangle.Left != null) ? ToPercentage(sourceRectangle.Right.Value) : 0;
                    double bottomPercentage = (sourceRectangle != null && sourceRectangle.Left != null) ? ToPercentage(sourceRectangle.Bottom.Value) : 0;

                    cropRectangle = new System.Drawing.Rectangle(
                        (int)(emf.Width * leftPercentage),
                        (int)(emf.Height * topPercentage),
                        (int)(emf.Width - emf.Width * (leftPercentage + rightPercentage)),
                        (int)(emf.Height - emf.Height * (bottomPercentage + topPercentage)));

                    System.Drawing.Bitmap newBmp = new System.Drawing.Bitmap(cropRectangle.Width, cropRectangle.Height);
                    using (System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(newBmp))
                    {
                        graphic.Clear(System.Drawing.Color.White);
                        graphic.DrawImage(emf, new System.Drawing.Rectangle(0, 0, cropRectangle.Width, cropRectangle.Height), cropRectangle, System.Drawing.GraphicsUnit.Pixel);
                    }
                    outputFile = outputFile.Replace(".emf", ".jpg");
                    newBmp.Save(outputFile, System.Drawing.Imaging.ImageFormat.Jpeg);
                    return outputFile;
                }
                else
                {
                    if (!File.Exists(outputFile))
                    {
                        using (FileStream outputStream = new FileStream(outputFile, fileMode, FileAccess.Write))
                        {
                            int cnt = 0;
                            const int LEN = 4096;
                            byte[] buffer = new byte[LEN];

                            while ((cnt = inputStream.Read(buffer, 0, LEN)) != 0)
                                outputStream.Write(buffer, 0, cnt);
                        }
                    }
                    return outputFile;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:nkravch,项目名称:SALMA-2.0,代码行数:66,代码来源:DocxToHtml.cs


示例6: GetCellValue

 private static string GetCellValue(SharedStringTable sharedStrings, DocumentFormat.OpenXml.Spreadsheet.Cell cell)
 {
     return cell.DataType != null
                 && cell.DataType.HasValue
                 && cell.DataType == CellValues.SharedString
               ? sharedStrings.ChildElements[
                 int.Parse(cell.CellValue.InnerText)].InnerText
               : cell.CellValue.InnerText;
 }
开发者ID:aureliopires,项目名称:gisa,代码行数:9,代码来源:ImportExcel2007Up.cs


示例7: FindPluginsTest1

 public void FindPluginsTest1()
 {
     DocumentFormat documentFormat = new DocumentFormat(); // TODO: Initialize to an appropriate value
     IEnumerable<IPlugin> expected = null; // TODO: Initialize to an appropriate value
     IEnumerable<IPlugin> actual;
     actual = PluginManager.FindPlugins(documentFormat);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
开发者ID:Tenere,项目名称:Semantic-Lib,代码行数:9,代码来源:PluginManagerTest.cs


示例8: ToOpenXmlElements

 public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
 {
     var result = new List<OpenXmlElement>();
     ForEachChild(x =>
     {
         Debug.Assert(x is ListItemFormattedElement);
         result.AddRange(x.ToOpenXmlElements(mainDocumentPart));
     });
     return result;
 }
开发者ID:julienblin,项目名称:RadarPOC,代码行数:10,代码来源:UnorderedListFormattedElement.cs


示例9: ToOpenXmlElements

 public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
 {
     TableRow result = new TableRow();
     ForEachChild(x =>
     {
         Debug.Assert(x is TableCellFormattedElement);
         result.Append(x.ToOpenXmlElements(mainDocumentPart));
     });
     return new List<OpenXmlElement> { result };
 }
开发者ID:julienblin,项目名称:RadarPOC,代码行数:10,代码来源:TableRowFormattedElement.cs


示例10: AddFormatToDocumentDescriptor

 public AddFormatToDocumentDescriptor(
     DocumentDescriptorId aggregateId, 
     DocumentFormat documentFormat, 
     BlobId blobId,
     PipelineId createdById) : base(aggregateId)
 {
     if (aggregateId == null) throw new ArgumentNullException("aggregateId");
     DocumentFormat = documentFormat;
     BlobId = blobId;
     CreatedBy = createdById;
 }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:11,代码来源:AddFormatToDocumentDescriptor.cs


示例11: ToOpenXmlElements

        public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
        {
            var result = new DocumentFormat.OpenXml.Wordprocessing.Run();
            var runProperties = new DocumentFormat.OpenXml.Wordprocessing.RunProperties();
            var boldProperty = new DocumentFormat.OpenXml.Wordprocessing.Bold();

            runProperties.Append(boldProperty);
            result.Append(runProperties);

            ForEachChild(x => result.Append(x.ToOpenXmlElements(mainDocumentPart)));
            return new List<OpenXmlElement> { result };
        }
开发者ID:julienblin,项目名称:RadarPOC,代码行数:12,代码来源:BoldFormattedElement.cs


示例12: ToOpenXmlElements

        public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
        {
            var result = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();

            var paragraphProperties = new ParagraphProperties();

            var numberingProperties = new NumberingProperties();
            var numberingLevelReference = new NumberingLevelReference() { Val = 0 };

            NumberingId numberingId;
            ParagraphStyleId paragraphStyleId;
            if (Parent is OrderedListFormattedElement)
            {
                paragraphStyleId = new ParagraphStyleId() { Val = "NumberedList" };
                numberingId = new NumberingId() { Val = ((OrderedListFormattedElement)Parent).NumberingInstanceId };

                var indentation = new Indentation() { Left = "1440", Hanging = "720" };
                paragraphProperties.Append(indentation);
            }
            else
            {
                paragraphStyleId = new ParagraphStyleId() { Val = "UnorderedListStyle" };
                numberingId = new NumberingId() { Val = 3 };
            }

            numberingProperties.Append(numberingLevelReference);
            numberingProperties.Append(numberingId);

            var spacingBetweenLines= new SpacingBetweenLines() { After = "100", AfterAutoSpacing = true };

            paragraphProperties.Append(paragraphStyleId);
            paragraphProperties.Append(numberingProperties);
            paragraphProperties.Append(spacingBetweenLines);
            result.Append(paragraphProperties);

            ForEachChild(x =>
            {
                if (x is TextFormattedElement)
                {
                    result.Append(
                        new DocumentFormat.OpenXml.Wordprocessing.Run(x.ToOpenXmlElements(mainDocumentPart))
                    );

                }
                else
                {
                    result.Append(x.ToOpenXmlElements(mainDocumentPart));
                }
            });

            return new List<OpenXmlElement> { result };
        }
开发者ID:julienblin,项目名称:RadarPOC,代码行数:52,代码来源:ListItemFormattedElement.cs


示例13: ToOpenXmlElements

        public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
        {
            var result = new List<OpenXmlElement>();
            ForEachChild(x =>
            {
                if (x is ParagraphFormattedElement)
                {
                    result.AddRange(x.ToOpenXmlElements(mainDocumentPart));
                }

            });
            return result;
        }
开发者ID:julienblin,项目名称:RadarPOC,代码行数:13,代码来源:FormattedContent.cs


示例14: SetCellValue

        public static void SetCellValue(WorksheetPart worksheetPart, decimal? value, string columnName, DocumentFormat.OpenXml.Spreadsheet.Row row, out Cell cell)
        {
            cell = GetCell(worksheetPart.Worksheet, columnName, row);

            if (value.HasValue)
            {
                cell.CellValue = new CellValue(value.ToString());
                cell.DataType = new EnumValue<CellValues>(CellValues.Number);
            }
            else
            {
                cell.CellValue = new CellValue();
                cell.DataType = new EnumValue<CellValues>(CellValues.InlineString);
            }
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:15,代码来源:ExcelTools.cs


示例15: AddCommentOnParagraph

        //Добавление комментария
        public void AddCommentOnParagraph(DocumentFormat.OpenXml.Wordprocessing.Paragraph comPar, string comment)
        {
            DocumentFormat.OpenXml.Wordprocessing.Comments comments = null;
                string id = "0";

                // Verify that the document contains a
                // WordProcessingCommentsPart part; if not, add a new one.
                if (document.MainDocumentPart.GetPartsCountOfType<WordprocessingCommentsPart>() > 0)
                {
                    comments =
                        document.MainDocumentPart.WordprocessingCommentsPart.Comments;
                    if (comments.HasChildren == true)
                    {
                        // Obtain an unused ID.
                        id = comments.Descendants<DocumentFormat.OpenXml.Wordprocessing.Comment>().Select(e => e.Id.Value).Max() + 1;
                    }
                }
                else
                {
                    // No WordprocessingCommentsPart part exists, so add one to the package.
                    WordprocessingCommentsPart commentPart = document.MainDocumentPart.AddNewPart<WordprocessingCommentsPart>();
                    commentPart.Comments = new DocumentFormat.OpenXml.Wordprocessing.Comments();
                    comments = commentPart.Comments;
                }

                // Compose a new Comment and add it to the Comments part.
                DocumentFormat.OpenXml.Wordprocessing.Paragraph p = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new Text(comment)));
                DocumentFormat.OpenXml.Wordprocessing.Comment cmt =
                    new DocumentFormat.OpenXml.Wordprocessing.Comment()
                    {
                        Id = id,
                        Author = "FRChecking System",
                        Date = DateTime.Now
                    };
                cmt.AppendChild(p);
                comments.AppendChild(cmt);
                comments.Save();

                // Specify the text range for the Comment.
                // Insert the new CommentRangeStart before the first run of paragraph.
                comPar.InsertBefore(new CommentRangeStart() { Id = id }, comPar.GetFirstChild<DocumentFormat.OpenXml.Wordprocessing.Run>());

                // Insert the new CommentRangeEnd after last run of paragraph.
                var cmtEnd = comPar.InsertAfter(new CommentRangeEnd() { Id = id }, comPar.Elements<DocumentFormat.OpenXml.Wordprocessing.Run>().Last());

                // Compose a run with CommentReference and insert it.
                comPar.InsertAfter(new DocumentFormat.OpenXml.Wordprocessing.Run(new CommentReference() { Id = id }), cmtEnd);
        }
开发者ID:mzhigalova,项目名称:FRCSystem,代码行数:49,代码来源:frmMain.cs


示例16: FileExtension

 /// <summary>
 /// Get the current default file extension for a document type. The method is not aware of the MS Compatibilty pack in 2003 or below
 /// </summary>
 /// <param name="type">target document type</param>
 /// <returns>default extension for document type</returns>
 public string FileExtension(DocumentFormat type)
 {
     switch (type)
     {
         case DocumentFormat.Normal:
             return _owner.ApplicationIs2007OrHigher ? "docx" : "doc";
         case DocumentFormat.Macros:
             return _owner.ApplicationIs2007OrHigher ? "docm" : "doc";
         case DocumentFormat.Template:
             return _owner.ApplicationIs2007OrHigher ? "dotx" : "dot";
         case DocumentFormat.TemplateMacros:
             return _owner.ApplicationIs2007OrHigher ? "dotm" : "dot";
         default:
             throw new ArgumentOutOfRangeException("type");
     }
 }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:21,代码来源:FileUtils.cs


示例17: GetByteArrayFromDocument

 public static byte[] GetByteArrayFromDocument(RichEditControl pRichEdit, DocumentFormat pDocFormat)
 {
     byte[] resultByteArray = null;
     try
     {
         using (MemoryStream memStream = new MemoryStream())
         {
             pRichEdit.SaveDocument(memStream, pDocFormat);
             resultByteArray = memStream.ToArray();
         }
     }
     catch (Exception e)
     {
     }
     return resultByteArray;
 }
开发者ID:Amphora2015,项目名称:DemoTest,代码行数:16,代码来源:WSUtils.cs


示例18: ToOpenXmlElements

        public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart)
        {
            var result = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();
            ForEachChild(x =>
            {
                if (x is TextFormattedElement)
                {
                    result.Append(
                        new DocumentFormat.OpenXml.Wordprocessing.Run(x.ToOpenXmlElements(mainDocumentPart))
                    );

                }
                else
                {
                    result.Append(x.ToOpenXmlElements(mainDocumentPart));
                }
            });
            return new List<OpenXmlElement> { result };
        }
开发者ID:julienblin,项目名称:RadarPOC,代码行数:19,代码来源:ParagraphFormattedElement.cs


示例19: FileExtension

 /// <summary>
 /// Get the current default file extension for a document type. The method is not aware of the MS Compatibilty pack in 2003 or below
 /// </summary>
 /// <param name="type">target document type</param>
 /// <returns>default extension for document type</returns>
 public string FileExtension(DocumentFormat type)
 {
     switch (type)
     {
         case DocumentFormat.Normal:
             return _owner.ApplicationIs2007OrHigher ? "xlsx" : "xls";
         case DocumentFormat.Macros:
             return _owner.ApplicationIs2007OrHigher ? "xlsm" : "xls";
         case DocumentFormat.Template:
             return _owner.ApplicationIs2007OrHigher ? "xltx" : "xlt";
         case DocumentFormat.TemplateMacros:
             return _owner.ApplicationIs2007OrHigher ? "xltm" : "xlt";
         case DocumentFormat.Binary:
             return "xlb";
         case DocumentFormat.AddinMacros:
             return _owner.ApplicationIs2007OrHigher ? "xlam" : "xla";
         default:
             throw new ArgumentOutOfRangeException("type");
     }
 }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:25,代码来源:FileUtils.cs


示例20: SaveByteArrayAsPdfFile

        /* External Service vs Internal Implementation Cross-Reference
         * Web API Architecture:
         *      ConfirmationsManager.svc.getConfirmTemplates = ConfirmDocsAPIDal.GetTemplates
         *      ConfirmationsManager.svc.getPermissionKeys = ConfirmMgrAPIDal.GetPermissionKeys
         *      ConfirmationsManager.svc.tradeConfirmationStatusChange = ConfirmMgrAPIDal...
         *      
         *      GetDocument.svc.getConfirmation = ConfirmDocsAPIDal.GetConfirm
         *      GetDocument.svc.getDealsheet = DealsheetAPIDal.GetDealsheet
         *  **********************************************************************************    
         *      CounterParty.svc.getAgreementList = CptyInfoAPIDal...
         *      CounterParty.svc.getDocumentSendTo = CptyInfoAPIDal...
         *      CounterParty.svc.storeDocumentSendTo = CptyInfoAPIDal...
         * 
         * ConfirmManager Architecture:
         *      ConfirmDocsAPIDal.GetTemplates = ConfirmationsManager.svc.getConfirmTemplates
         *      ConfirmDocsAPIDal.GetConfirm = GetDocument.svc.getConfirmation  
         *
         *      ConfirmMgrAPIDal.GetPermissionKeys = ConfirmationsManager.svc.getPermissionKeys
         *      ConfirmMgrAPIDal... = ConfirmationsManager.svc.tradeConfirmationStatusChange
         *      
         *      DealsheetAPIDal.GetDealsheet = GetDocument.svc.getDealsheet
         *  **********************************************************************************          
         *      CptyInfoAPIDal... = CounterParty.svc.getAgreementList 
         *      CptyInfoAPIDal... = CounterParty.svc.getDocumentSendTo 
         *      CptyInfoAPIDal... = CounterParty.svc.storeDocumentSendTo
         * 
        */

        public static bool SaveByteArrayAsPdfFile(byte[] pByteArray, DocumentFormat pDocFormat, string pFileName)
        {
            bool isConversionOk = false;
            RichEditControl richEdit = new RichEditControl();
            try
            {
                using (MemoryStream memStream = new MemoryStream(pByteArray))
                {
                    richEdit.LoadDocument(memStream, pDocFormat);
                    richEdit.ExportToPdf(pFileName);
                }

                isConversionOk = true;
            }
            catch (Exception e)
            {
                isConversionOk = false;
            }
            return isConversionOk;
        }
开发者ID:Amphora2015,项目名称:DemoTest,代码行数:48,代码来源:WSUtils.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DocumentId类代码示例发布时间:2022-05-24
下一篇:
C# DocumentEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap