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


C# DocumentFormat类代码示例

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


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


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