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

C# SpreadsheetDocument类代码示例

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

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



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

示例1: CreateParts

        // Adds child parts and generates content of the specified part.
        private void CreateParts(SpreadsheetDocument document)
        {
            ExtendedFilePropertiesPart extendedFilePropertiesPart1 = document.AddNewPart<ExtendedFilePropertiesPart>("rId3");
            GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart1);

            WorkbookPart workbookPart1 = document.AddWorkbookPart();
            GenerateWorkbookPart1Content(workbookPart1);

            WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart<WorkbookStylesPart>("rId3");
            GenerateWorkbookStylesPart1Content(workbookStylesPart1);

            ThemePart themePart1 = workbookPart1.AddNewPart<ThemePart>("rId2");
            GenerateThemePart1Content(themePart1);

            WorksheetPart worksheetPart1 = workbookPart1.AddNewPart<WorksheetPart>("rId1");
            GenerateWorksheetPart1Content(worksheetPart1);

            DrawingsPart drawingsPart1 = worksheetPart1.AddNewPart<DrawingsPart>("rId2");
            GenerateDrawingsPart1Content(drawingsPart1);

            ImagePart imagePart1 = drawingsPart1.AddNewPart<ImagePart>("image/jpeg", "rId1");
            GenerateImagePart1Content(imagePart1);

            SpreadsheetPrinterSettingsPart spreadsheetPrinterSettingsPart1 = worksheetPart1.AddNewPart<SpreadsheetPrinterSettingsPart>("rId1");
            GenerateSpreadsheetPrinterSettingsPart1Content(spreadsheetPrinterSettingsPart1);

            CalculationChainPart calculationChainPart1 = workbookPart1.AddNewPart<CalculationChainPart>("rId5");
            GenerateCalculationChainPart1Content(calculationChainPart1);

            SharedStringTablePart sharedStringTablePart1 = workbookPart1.AddNewPart<SharedStringTablePart>("rId4");
            GenerateSharedStringTablePart1Content(sharedStringTablePart1);

            SetPackageProperties(document);
        }
开发者ID:javierlov,项目名称:PautasElectronica,代码行数:35,代码来源:csOP_TEST.cs


示例2: XLGetCell

 public static Cell XLGetCell(SpreadsheetDocument document, string sheetName, string columnName, uint rowIndex)
 {
     Sheet theSheet = XLGetSheet(document, sheetName);
     // Throw an exception if there is no sheet.
     if (theSheet == null) throw new ArgumentException("sheetName");
     return XLGetCell(document, theSheet, columnName, rowIndex);
 }
开发者ID:ZiggyMaes,项目名称:NMCT-Business-Applications,代码行数:7,代码来源:OpenXMLExcel.cs


示例3: GetStylesDocument

 /// <summary>
 /// XDocument containing Xml content of the styles part
 /// </summary>
 public static XDocument GetStylesDocument(SpreadsheetDocument document)
 {
     if (document.WorkbookPart.WorkbookStylesPart != null)
         return document.WorkbookPart.WorkbookStylesPart.GetXDocument();
     else
         return null;
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:10,代码来源:SpreadSheetStyleAccessor.cs


示例4: CreateParts

        private void CreateParts(SpreadsheetDocument document)
        {
            WorkbookPart workbookPart1 = document.AddWorkbookPart();
            GenerateWorkbookPart1Content(workbookPart1);

            // Create sharedstring
            SharedStringTablePart sharedStringTablePart1 = workbookPart1.AddNewPart<SharedStringTablePart>("rId7");
            GenerateSharedStringTablePart1Content(sharedStringTablePart1);

            // Create Sheet2
            WorksheetPart worksheetPart2 = workbookPart1.AddNewPart<WorksheetPart>("rId2");
            GenerateWorksheetPart2Content(worksheetPart2);

            // Create Sheet1
            WorksheetPart worksheetPart3 = workbookPart1.AddNewPart<WorksheetPart>("rId1");
            GenerateWorksheetPart3Content(worksheetPart3);

            // Add PivotTablePart to Sheet1
            PivotTablePart pivotTablePart1 = worksheetPart3.AddNewPart<PivotTablePart>("rId1");
            GeneratePivotTablePart1Content(pivotTablePart1);

            // Add PivotTableCacheDefinitionPart to PivotTablePart
            PivotTableCacheDefinitionPart pivotTableCacheDefinitionPart1 = pivotTablePart1.AddNewPart<PivotTableCacheDefinitionPart>("rId1");
            GeneratePivotTableCacheDefinitionPart1Content(pivotTableCacheDefinitionPart1);

            // Add PivotTableCacheDefinitionPart to PivotTableCacheDefinitionPart
            PivotTableCacheRecordsPart pivotTableCacheRecordsPart1 = pivotTableCacheDefinitionPart1.AddNewPart<PivotTableCacheRecordsPart>("rId1");
            GeneratePivotTableCacheRecordsPart1Content(pivotTableCacheRecordsPart1);

            WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart<WorkbookStylesPart>("rId6");
            GenerateWorkbookStylesPart1Content(workbookStylesPart1);

            workbookPart1.AddPart(pivotTableCacheDefinitionPart1, "rId4");
        }
开发者ID:DigitalJo,项目名称:jordanius-repository,代码行数:34,代码来源:GeneratedClass.cs


示例5: XLGetCellValue

 public static string XLGetCellValue(SpreadsheetDocument document, string sheetName, string columnName, uint rowIndex)
 {
     Cell cell = XLGetCell(document, sheetName, columnName, rowIndex);
     string value = null;
     if (cell != null) value = XLInterpretedCellValue(document, cell);
     return value;
 }
开发者ID:ZiggyMaes,项目名称:NMCT-Business-Applications,代码行数:7,代码来源:OpenXMLExcel.cs


示例6: InsertTextIntoCells

        /// <summary>
        /// Creates the content of the shet (columns, rows, cells)
        /// </summary>
        /// <param name="spreadsheetDocument">The spreadsheet containing the sheets</param>
        /// <param name="worksheetPart">The worksheetpart for this item</param>
        private void InsertTextIntoCells(SpreadsheetDocument spreadsheetDocument, WorksheetPart worksheetPart)
        {
            // Get the SharedStringTablePart. If it does not exist, create a new one.
            SharedStringTablePart shareStringPart;
            if (spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().Any())
            {
                shareStringPart = spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First();
            }
            else
            {
                shareStringPart = spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
            }

            #region Excel headers

            string header1 = "ResourceTypeID";
            int index1 = _sharedResources.InsertSharedStringItem(header1, shareStringPart);
            Cell headerCell1 = _sharedResources.InsertCellInWorksheet("A", 1, worksheetPart);
            headerCell1.CellValue = new CellValue(index1.ToString(CultureInfo.InvariantCulture));
            headerCell1.DataType = new EnumValue<CellValues>(CellValues.SharedString);

            string header2 = "ResourceType";
            int index2 = _sharedResources.InsertSharedStringItem(header2, shareStringPart);
            Cell headerCell2 = _sharedResources.InsertCellInWorksheet("B", 1, worksheetPart);
            headerCell2.CellValue = new CellValue(index2.ToString(CultureInfo.InvariantCulture));
            headerCell2.DataType = new EnumValue<CellValues>(CellValues.SharedString);

            #endregion

            #region insert the items from the temporary list into the ktUIOrder excel sheet

            int columnCount = 1;
            uint rowCount = 2;

            foreach (ktResourceType resourceType in _resourceType.ktResourceTypeList)
            {
                    if (columnCount >= 2)
                    {
                        columnCount = 1;
                    }

                    string text1 = resourceType.ResourceTypeID;
                    Cell cell1 = _sharedResources.InsertCellInWorksheet(_sharedResources.Number2String(columnCount, true), rowCount, worksheetPart);
                    cell1.CellValue = new CellValue(text1);
                    cell1.DataType = CellValues.Number;
                    columnCount++;

                    string text2 = resourceType.ResourceType;
                    Cell cell2 = _sharedResources.InsertCellInWorksheet(_sharedResources.Number2String(columnCount, true), rowCount, worksheetPart);
                    cell2.CellValue = new CellValue(text2);
                    cell2.DataType = CellValues.String;
                    columnCount++;

                    rowCount++;
            }

            #endregion

            worksheetPart.Worksheet.Save();
        }
开发者ID:Bulgrak,项目名称:praktikpbasw,代码行数:65,代码来源:ResourceType.cs


示例7: ExcelStreamReader

 private ExcelStreamReader(string fileName)
 {
     this.fileName = fileName;
     this.doc = SpreadsheetDocument.Open(fileName, false);
     this.workbookPart = doc.WorkbookPart;
     this.sheets = GetSheets();
 }
开发者ID:PeterHenell,项目名称:OpenXMLExcelStreamReader,代码行数:7,代码来源:ExcelStreamReader.cs


示例8: CreateParts

        // Adds child parts and generates content of the specified part.
        private void CreateParts(SpreadsheetDocument document)
        {
            ExtendedFilePropertiesPart extendedFilePropertiesPart1 = document.AddNewPart<ExtendedFilePropertiesPart>("rId3");
            GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart1);

            WorkbookPart workbookPart1 = document.AddWorkbookPart();
            GenerateWorkbookPart1Content(workbookPart1);

            WorksheetPart worksheetPart1 = workbookPart1.AddNewPart<WorksheetPart>("rId3");
            GenerateWorksheetPart1Content(worksheetPart1);

            WorksheetPart worksheetPart2 = workbookPart1.AddNewPart<WorksheetPart>("rId2");
            GenerateWorksheetPart2Content(worksheetPart2);

            WorksheetPart worksheetPart3 = workbookPart1.AddNewPart<WorksheetPart>("rId1");
            GenerateWorksheetPart3Content(worksheetPart3);

            WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart<WorkbookStylesPart>("rId5");
            GenerateWorkbookStylesPart1Content(workbookStylesPart1);

            ThemePart themePart1 = workbookPart1.AddNewPart<ThemePart>("rId4");
            GenerateThemePart1Content(themePart1);

            SetPackageProperties(document);
        }
开发者ID:FerHenrique,项目名称:Owl,代码行数:26,代码来源:DocumentCreator.cs


示例9: Create

        /// <summary>
        /// Creates a spreadsheet document from a value table
        /// </summary>
        /// <param name="filePath">Path to store the document</param>
        /// <param name="headerList">Contents of first row (header)</param>
        /// <param name="valueTable">Contents of data</param>
        /// <param name="initialRow">Row to start copying data from</param>
        /// <returns></returns>
        public static void Create(SpreadsheetDocument document, List<string> headerList, string[][] valueTable, int initialRow)
        {
            headerRow = initialRow;

            //Creates a worksheet with given data
            WorksheetPart worksheet = WorksheetAccessor.Create(document, headerList, valueTable, headerRow);
        }
开发者ID:BogdanDamianC,项目名称:Open-Xml-PowerTools,代码行数:15,代码来源:SpreadsheetDocumentManager.cs


示例10: Print

        public void Print(SpreadsheetDocument document)
        {
            var extendedFilePropertiesPart = document.AddNewPart<ExtendedFilePropertiesPart>("rId3");
            generateExtendedFilePropertiesPartContent(extendedFilePropertiesPart);

            var workbookPart = document.AddWorkbookPart();
            generateWorkbookPartContent(workbookPart);

            var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>("rId3");
            GenerateWorkbookStylesPartContent(workbookStylesPart);

            var themePart = workbookPart.AddNewPart<ThemePart>("rId2");
            generateThemePartContent(themePart);

            var worksheetPart = workbookPart.AddNewPart<WorksheetPart>("rId1");
            GenerateWorksheetPartContent(worksheetPart);

            var spreadsheetPrinterSettingsPart = worksheetPart.AddNewPart<SpreadsheetPrinterSettingsPart>("rId1");
            generateSpreadsheetPrinterSettingsPartContent(spreadsheetPrinterSettingsPart);

            var sharedStringTablePart = workbookPart.AddNewPart<SharedStringTablePart>("rId4");
            GenerateSharedStringTablePartContent(sharedStringTablePart);

            setPackageProperties(document);
        }
开发者ID:CourageAndrey,项目名称:Workflow,代码行数:25,代码来源:ExcelDocument.cs


示例11: ReadToBook

 public xlBook ReadToBook(SpreadsheetDocument document)
 {
     using (_docProvider = new DocDictionaries(document, _config.AutoDispose))
     {
         xlBook result = new xlBook();
         for (int i = 0; i < document.WorkbookPart.WorksheetParts.Count(); i++)
         {
             result.AddSheet(_docProvider.sheetNames[i]);
             var sheet = document.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>().SingleOrDefault(s => s.Name == _docProvider.sheetNames[i]);
             var worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheet.Id.Value);
             foreach (var cell in worksheetPart.Worksheet.GetFirstChild<SheetData>().Descendants<Cell>())
             {
                 try
                 {
                     if (cell == null) { continue; }
                     result[i].Cells.Add(ReadCell(cell));
                 }
                 catch (Exception)
                 {
                     if (_config.ContinueOnRowReadingError) continue; else throw;
                 }
             }
         }
         return result;
     }
 }
开发者ID:ConstKosyanov,项目名称:xlOC-Excel-to-Object-Converter,代码行数:26,代码来源:xlBookReader.cs


示例12: DocDictionaries

 public DocDictionaries(SpreadsheetDocument document, bool AutoDispose)
 {
     _autoDispose = AutoDispose;
     this.document = document;
     sharedStrings = document.WorkbookPart.SharedStringTablePart.SharedStringTable.Select(x => x.InnerText).ToArray();
     sheetNames = document.WorkbookPart.Workbook.Sheets.Cast<Sheet>().Select(x => x.Name.Value).ToArray();
     styles = document.WorkbookPart.WorkbookStylesPart.Stylesheet.CellFormats.Cast<CellFormat>().ToArray();
 }
开发者ID:ConstKosyanov,项目名称:xlOC-Excel-to-Object-Converter,代码行数:8,代码来源:DocData.cs


示例13: ExcellWorker

 /// <summary>
 /// Создает экземпляр класса для работы с текущим файлом
 /// </summary>
 /// <param name="filePath">Путь к документу</param>
 /// <param name="removeAfterDestroy">Удалять ли файл после окончания работы с ним</param>
 public ExcellWorker(string filePath, bool removeAfterDestroy)
 {
     _currentFilePath = filePath;
     _currentDocument = SpreadsheetDocument.Open(filePath, true);
     _currentWorkBookPart = _currentDocument.WorkbookPart;
     _currentSheet = _currentWorkBookPart.Workbook.Descendants<Sheet>().FirstOrDefault();
     RemoveAfterDestroy = removeAfterDestroy;
 }
开发者ID:gerasyana,项目名称:Academy,代码行数:13,代码来源:ExcellWorker.cs


示例14: RenderSpreadSheetDocument_OpenXmlSdk

 public RenderSpreadSheetDocument_OpenXmlSdk(Report report, IStreamGen sg)
     : base(report, sg)
 {
     _ms = new MemoryStream();
     _spreadSheet = SpreadsheetDocument.Create(_ms, SpreadsheetDocumentType.Workbook);
     _openXmlExportHelper = new OpenXmlWriterHelper();
     _workbook = new Workbook();
     _workSheetSettings = new List<WorkSheetSetting>();
 }
开发者ID:daniellor,项目名称:My-FyiReporting,代码行数:9,代码来源:RenderSpreadSheetDocument_OpenXmlSdk.cs


示例15: ExcelDataReader

        public ExcelDataReader(string path, int sheetIndex = 0, bool firstRowAsHeader = true)
        {
            _document = SpreadsheetDocument.Open(path, false);
            _sharedStrings = GetSharedStrings(_document);

            var worksheetPart = _document.WorkbookPart.GetPartById(GetSheetByIndex(sheetIndex).Id.Value);
            _reader = OpenXmlReader.Create(worksheetPart);
            _headers = firstRowAsHeader ? GetFirstRowAsHeaders() : GetRangeHeaders(worksheetPart);
        }
开发者ID:gSerP1983,项目名称:OpenXml.Excel.Data,代码行数:9,代码来源:ExcelDataReader.cs


示例16: ExcelTemplate

 protected ExcelTemplate(string fileName)
 {
     mStream = new MemoryStream();
     using (var fileStream = File.OpenRead(fileName))
     {
         fileStream.CopyTo(mStream);
     }
     mSpreadSheet = SpreadsheetDocument.Open(mStream, true);
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:9,代码来源:ExcelTemplate.cs


示例17: UpdateParts

        private void UpdateParts(SpreadsheetDocument document, Dictionary<WorksheetPart, List<ExcelSheet>> worksheetsWithRows, List<ProjectFile> projectFiles, Customer customer, User user)
        {
            var workSheets = document.WorkbookPart.WorksheetParts;

            foreach (var workSheet in workSheets)
            {
                UpdateWorksheetContent(workSheet, worksheetsWithRows[workSheet], document.WorkbookPart.SharedStringTablePart.SharedStringTable, projectFiles, customer, user);
            }
        }
开发者ID:desautel,项目名称:Sdl-Community,代码行数:9,代码来源:ExcelHelperBase.cs


示例18: GetAllWorksheets

 public static List<Worksheet> GetAllWorksheets(SpreadsheetDocument spreadsheet)
 {
     var worksheets = new List<Worksheet>();
     var worksheetParts = ExcelSpreadsheet.GetAllWorksheetParts(spreadsheet);
     foreach (WorksheetPart itemWorksheetPart in worksheetParts)
     {
         worksheets.Add(itemWorksheetPart.Worksheet);
     }
     return worksheets;
 }
开发者ID:dev01github,项目名称:openxml-25-sample,代码行数:10,代码来源:ExcelSpreadsheet.cs


示例19: Create

 public ExcelHelper Create(string ExcelFile)
 {
     System.IO.FileInfo fi = new System.IO.FileInfo(ExcelFile);
     if (!fi.Directory.Exists)
         fi.Directory.Create();
     _doc = SpreadsheetDocument.Create(ExcelFile, SpreadsheetDocumentType.Workbook);
     _wbPart = _doc.AddWorkbookPart();
     _wbPart.Workbook = new Workbook();
     _doc.WorkbookPart.Workbook.AppendChild<Sheets>(new Sheets());
     return _instance;
 }
开发者ID:Jason-Brody,项目名称:Young,代码行数:11,代码来源:ExcelHelper.cs


示例20: GetCellFormat

 private CellFormat GetCellFormat(SpreadsheetDocument doc, Cell cell)
 {
     var index = (int) cell.StyleIndex.Value;
     var cellFormat = doc.WorkbookPart
                         .WorkbookStylesPart
                         .Stylesheet
                         .CellFormats
                         .Elements<CellFormat>()
                         .ElementAt(index);
     return cellFormat;
 }
开发者ID:echen-mdsol,项目名称:Medidata.Cloud.Tsdv.Loader,代码行数:11,代码来源:AutoFitColumnSheetDecorator.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Sprite类代码示例发布时间:2022-05-24
下一篇:
C# Spinner类代码示例发布时间: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