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

C# IWorkbook类代码示例

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

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



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

示例1: Calculate

 public double? Calculate(IWorkbook book)
 {
     var func = _calc.Build(this.StringExpressionPart);
     var paramDict = this.Variables.ToDictionary(k => k.Key, v => GetCellValue(v.Value, book));
     this.Result = func.Invoke(paramDict);
     return this.Result;
 }
开发者ID:superbatonchik,项目名称:EduFormManager,代码行数:7,代码来源:FormulaExpressionPart.cs


示例2: GetBaseStyle

 private ICellStyle GetBaseStyle(IWorkbook workbook)
 {
     var style = workbook.CreateCellStyle();
     style.BorderBottom = style.BorderLeft = style.BorderRight = style.BorderTop = BorderStyle.Thin;
     style.FillPattern = FillPattern.SolidForeground;
     return style;
 }
开发者ID:McLeanBH,项目名称:XbimExchange,代码行数:7,代码来源:ExcelCellVisualValue.cs


示例3: SetValueAndFormat

 static void SetValueAndFormat(IWorkbook workbook, ICell cell, double value, short formatId)
 {
     cell.SetCellValue(value);
     ICellStyle cellStyle = workbook.CreateCellStyle();
     cellStyle.DataFormat = formatId;
     cell.CellStyle = cellStyle;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:7,代码来源:Program.cs


示例4: CreateCell

        internal static ICell CreateCell(IWorkbook workbook, IRow row, int column, decimal? content, bool isCentered)
        {
            ICellStyle style = workbook.CreateCellStyle();
            ICell cell = row.CreateCell(column);
            if (content == null)
            {
                cell.SetCellValue("");
            }
            else
            {
                cell.SetCellValue(Convert.ToDouble(content.Value));
            }
            if (isCentered)
            {
                style.Alignment = HorizontalAlignment.Center;

            }
            style.BorderBottom = BorderStyle.Thin;
            style.BorderTop = BorderStyle.Thin;
            style.BorderLeft = BorderStyle.Thin;
            style.BorderRight = BorderStyle.Thin;

            cell.CellStyle = style;
            return cell;
        }
开发者ID:chamilka,项目名称:drreport,代码行数:25,代码来源:CellManager.cs


示例5: FillData

        private void FillData(IWorkbook p_wb)
        {
            ISheet sheet = p_wb.CreateSheet("sheet123");
            sheet.RowSumsBelow = (/*setter*/false);
            int i;
            for (i = 0; i < ROWS_NUMBER; i++)
            {
                IRow row = sheet.CreateRow(i);
                ICell cell = row.CreateCell(0);
                cell.SetCellValue(i + 1);
            }

            i = 1;
            while (i < ROWS_NUMBER)
            {
                int end = i + (GROUP_SIZE - 2);
                int start = i;                    // natural order
                //            int start = end - 1;                // reverse order
                while (start < end)
                {             // natural order
                    //                while (start >= i) {            // reverse order
                    sheet.GroupRow(start, end);
                    //o_groupsNumber++;
                    bool collapsed = IsCollapsed();
                    //System.out.Println("Set group " + start + "->" + end + " to " + collapsed);
                    sheet.SetRowGroupCollapsed(start, collapsed);
                    start++;                      // natural order
                    //                start--;                        // reverse order
                }
                i += GROUP_SIZE;
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:32,代码来源:TestXSSFSheetRowGrouping.cs


示例6: CheckExpression

 public CheckExpression(string expression, IWorkbook workbook)
 {
     this.StringExpression = expression;
     this.Workbook = workbook;
     this.Cells = new List<Cell>();
     this.ErrorMessages = new List<string>();
 }
开发者ID:superbatonchik,项目名称:EduFormManager,代码行数:7,代码来源:CheckExpression.cs


示例7: WriteOutAndReadBack

 public static IWorkbook WriteOutAndReadBack(IWorkbook wb)
 {
     IWorkbook result;
     try
     {
         using (MemoryStream baos = new MemoryStream(8192))
         {
             wb.Write(baos);
             using (Stream is1 = new MemoryStream(baos.ToArray()))
             {
                 if (wb is HSSFWorkbook)
                 {
                     result = new HSSFWorkbook(is1);
                 }
                 else if (wb is XSSFWorkbook)
                 {
                     result = new XSSFWorkbook(is1);
                 }
                 else
                 {
                     throw new RuntimeException("Unexpected workbook type ("
                             + wb.GetType().Name + ")");
                 }
             }
         }
     }
     catch (IOException e)
     {
         throw new RuntimeException(e);
     }
     return result;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:32,代码来源:XSSFTestDataSamples.cs


示例8: CellStyleCache

 public CellStyleCache(IWorkbook xlWorkbook)
 {
     this.xlWorkbook = xlWorkbook;
       this.cellStyles = new Dictionary<string, CellStyleWrapper>();
       this.cellStyle = xlWorkbook.CreateCellStyle();
       this.defaultCellStyle = xlWorkbook.CreateCellStyle();
 }
开发者ID:Stef569,项目名称:npoi-wrapper,代码行数:7,代码来源:CellStyleCache.cs


示例9: AssertDataValidation

        public void AssertDataValidation(IWorkbook wb)
        {

            MemoryStream baos = new MemoryStream(22000);
            try
            {
                wb.Write(baos);
                baos.Close();
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            byte[] generatedContent = baos.ToArray();
#if !HIDE_UNREACHABLE_CODE
            bool isSame;
            if (false)
            {
                // TODO - add proof spreadsheet and compare
                Stream proofStream = HSSFTestDataSamples.OpenSampleFileStream("TestDataValidation.xls");
                isSame = CompareStreams(proofStream, generatedContent);
            }
            isSame = true;

            if (isSame)
            {
                return;
            }

            //File tempDir = new File(System.GetProperty("java.io.tmpdir"));
            string tempDir = Path.GetTempFileName();
            //File generatedFile = new File(tempDir, "GeneratedTestDataValidation.xls");
            try
            {
                FileStream fileOut = new FileStream(tempDir, FileMode.Create);
                fileOut.Write(generatedContent, 0, generatedContent.Length);
                fileOut.Close();
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }


            Console.WriteLine("This Test case has failed because the generated file differs from proof copy '"
                    ); // TODO+ proofFile.AbsolutePath + "'.");
            Console.WriteLine("The cause is usually a change to this Test, or some common spreadsheet generation code.  "
                    + "The developer has to decide whether the Changes were wanted or unwanted.");
            Console.WriteLine("If the Changes to the generated version were unwanted, "
                    + "make the fix elsewhere (do not modify this Test or the proof spreadsheet to Get the Test working).");
            Console.WriteLine("If the Changes were wanted, make sure to open the newly generated file in Excel "
                    + "and verify it manually.  The new proof file should be submitted After it is verified to be correct.");
            Console.WriteLine("");
            Console.WriteLine("One other possible (but less likely) cause of a failed Test is a problem in the "
                    + "comparison logic used here. Perhaps some extra file regions need to be ignored.");
            Console.WriteLine("The generated file has been saved to '" + tempDir + "' for manual inspection.");

            Assert.Fail("Generated file differs from proof copy.  See sysout comments for details on how to fix.");
#endif
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:60,代码来源:TestDataValidation.cs


示例10: Confirm

        private void Confirm(IWorkbook wb)
        {
            ISheet sheet = wb.CreateSheet("new sheet");
            cell11 = sheet.CreateRow(0).CreateCell(0);
            cell11.SetCellType(CellType.Formula);

            Confirm("PROPER(\"hi there\")", "Hi There");
            Confirm("PROPER(\"what's up\")", "What'S Up");
            Confirm("PROPER(\"I DON'T TH!NK SO!\")", "I Don'T Th!Nk So!");
            Confirm("PROPER(\"dr\u00dcb\u00f6'\u00e4 \u00e9lo\u015f|\u00eb\u00e8 \")", "Dr\u00fcb\u00f6'\u00c4 \u00c9lo\u015f|\u00cb\u00e8 ");
            Confirm("PROPER(\"hi123 the123re\")", "Hi123 The123Re");
            Confirm("PROPER(\"-\")", "-");
            Confirm("PROPER(\"!\u00a7$\")", "!\u00a7$");
            Confirm("PROPER(\"/&%\")", "/&%");

            // also test longer string
            StringBuilder builder = new StringBuilder("A");
            StringBuilder expected = new StringBuilder("A");
            for (int i = 1; i < 254; i++)
            {
                builder.Append((char)(65 + (i % 26)));
                expected.Append((char)(97 + (i % 26)));
            }
            Confirm("PROPER(\"" + builder.ToString() + "\")", expected.ToString());
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:25,代码来源:TestProper.cs


示例11: AddComment

        /// <summary>
        /// To insert comment in active sheet
        /// </summary>
        /// <param name="workbook">Instance of IWorkbook</param>
        /// <param name="cellAddress">Address of cell</param>
        /// <param name="comment">Comment string</param>
        /// <param name="clearOldComments">True/False. True to clear old comments</param>
        internal static void AddComment(IWorkbook workbook, string cellAddress, string comment, bool clearOldComments)
        {
            SpreadsheetGear.IRange Cell;
            SpreadsheetGear.IComment CellComment;
            try
            {
                // Get a reference to a cell.
                Cell = workbook.ActiveWorksheet.Cells[cellAddress];
                // If the cell has no comment, add one.
                if (Cell.Comment != null & clearOldComments)
                {
                    Cell.ClearComments();
                }

                CellComment = Cell.AddComment(comment);

                // Turn off the default bold font.
                CellComment.Shape.TextFrame.Characters.Font.Bold = false;
                //CellComment.Visible = true;
            }
            catch (Exception ex)
            {
                //                new ApplicationException(ex.ToString());
            }
        }
开发者ID:SDRC-India,项目名称:sdrcdevinfo,代码行数:32,代码来源:ExcelHelper.cs


示例12: WriteHeaderRow

 static void WriteHeaderRow(IWorkbook wb, ISheet sheet)
 {
     sheet.SetColumnWidth(0, 6000);
     sheet.SetColumnWidth(1, 6000);
     sheet.SetColumnWidth(2, 3600);
     sheet.SetColumnWidth(3, 3600);
     sheet.SetColumnWidth(4, 2400);
     sheet.SetColumnWidth(5, 2400);
     sheet.SetColumnWidth(6, 2400);
     sheet.SetColumnWidth(7, 2400);
     sheet.SetColumnWidth(8, 2400);
     IRow row = sheet.CreateRow(0);
     ICellStyle style = wb.CreateCellStyle();
     IFont font = wb.CreateFont();
     font.Boldweight = (short)FontBoldWeight.BOLD;
     style.SetFont(font);
     WriteHeaderCell(row, 0, "Raw Long Bits A", style);
     WriteHeaderCell(row, 1, "Raw Long Bits B", style);
     WriteHeaderCell(row, 2, "Value A", style);
     WriteHeaderCell(row, 3, "Value B", style);
     WriteHeaderCell(row, 4, "Exp Cmp", style);
     WriteHeaderCell(row, 5, "LT", style);
     WriteHeaderCell(row, 6, "EQ", style);
     WriteHeaderCell(row, 7, "GT", style);
     WriteHeaderCell(row, 8, "Check", style);
 }
开发者ID:xoposhiy,项目名称:npoi,代码行数:26,代码来源:NumberComparingSpreadsheetGenerator.cs


示例13: buildWorkbook

        private void buildWorkbook(IWorkbook wb)
        {
            ISheet sh = wb.CreateSheet();
            IRow row1 = sh.CreateRow(0);
            IRow row2 = sh.CreateRow(1);
            row3 = sh.CreateRow(2);

            row1.CreateCell(0, CellType.Numeric);
            row1.CreateCell(1, CellType.Numeric);

            row2.CreateCell(0, CellType.Numeric);
            row2.CreateCell(1, CellType.Numeric);

            row3.CreateCell(0);
            row3.CreateCell(1);

            CellReference a1 = new CellReference("A1");
            CellReference a2 = new CellReference("A2");
            CellReference b1 = new CellReference("B1");
            CellReference b2 = new CellReference("B2");

            sh.GetRow(a1.Row).GetCell(a1.Col).SetCellValue(35);
            sh.GetRow(a2.Row).GetCell(a2.Col).SetCellValue(0);
            sh.GetRow(b1.Row).GetCell(b1.Col).CellFormula = (/*setter*/"A1/A2");
            sh.GetRow(b2.Row).GetCell(b2.Col).CellFormula = (/*setter*/"NA()");

            Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:28,代码来源:TestLogicalFunction.cs


示例14: BorderAndFontSetting

        private ICellStyle BorderAndFontSetting(IWorkbook wb, Tk5FieldInfoEx metaInfo, Model model)
        {
            ICellStyle cellStyle = wb.CreateCellStyle();

            if (fUseBorder)
            {
                cellStyle.BorderTop = BorderStyle.Thin;
                cellStyle.BorderRight = BorderStyle.Thin;
                cellStyle.BorderBottom = BorderStyle.Thin;
                cellStyle.BorderLeft = BorderStyle.Thin;
            }

            if (model == Model.Content)
            {
                IFont fontContent = ExcelUtil.FontSetting(wb, fContent);

                cellStyle.SetFont(fontContent);

                if (metaInfo.Extension != null)
                {
                    ExcelUtil.AlignSetting(metaInfo.Extension.Align, cellStyle);
                }
                else
                {
                    ExcelUtil.AlignSetting(fContent.Align, cellStyle);
                }
            }
            else
            {
                ExcelUtil.AlignSetting(fHeader.Align, cellStyle);
                IFont fontHeader = ExcelUtil.FontSetting(wb, fHeader);
                cellStyle.SetFont(fontHeader);
            }
            return cellStyle;
        }
开发者ID:ZLLselfRedeem,项目名称:zllinmitu,代码行数:35,代码来源:ExcelExporter.cs


示例15: WorkSheet

        internal WorkSheet(IWorkbook bookHandler, ISheet sheetHandler)
        {
            this.bookHandler = bookHandler;
            this.sheetHandler = sheetHandler;

            this.Cells = new CellCollection() { Sheet = this };
        }
开发者ID:vjine,项目名称:NPOI.Wrapper,代码行数:7,代码来源:WorkSheet.cs


示例16: WriteOutAndReadBack

 public IWorkbook WriteOutAndReadBack(IWorkbook original)
 {
     if (!(original is XSSFWorkbook))
     {
         throw new ArgumentException("Expected an instance of XSSFWorkbook, but had " + original.GetType().Name);
     }
     return XSSFTestDataSamples.WriteOutAndReadBack((XSSFWorkbook)original);
 }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:8,代码来源:XSSFITestDataProvider.cs


示例17: Create

 public static XSSFEvaluationWorkbook Create(IWorkbook book)
 {
     if (book == null)
     {
         return null;
     }
     return new XSSFEvaluationWorkbook(book);
 }
开发者ID:myblindy,项目名称:npoi,代码行数:8,代码来源:XSSFEvaluationWorkbook.cs


示例18: LoadImage

        public static int LoadImage(string path, IWorkbook wb)
        {
            FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
            byte[] buffer = new byte[file.Length];
            file.Read(buffer, 0, (int)file.Length);
            return wb.AddPicture(buffer, PictureType.JPEG);

        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:8,代码来源:Program.cs


示例19: SheetWriter

            public SheetWriter(IWorkbook wb)
            {
                ISheet sheet = wb.CreateSheet("Sheet1");

                WriteHeaderRow(wb, sheet);
                _sheet = sheet;
                _rowIndex = 1;
            }
开发者ID:xoposhiy,项目名称:npoi,代码行数:8,代码来源:NumberComparingSpreadsheetGenerator.cs


示例20: Init

 private void Init()
 {
     #region//初始化信息
     try
     {
         using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
         {
             if (filePath.Trim().ToLower().EndsWith(".xls"))
             {
                 hssfworkbook = new HSSFWorkbook(file);
             }
             else if (filePath.Trim().ToLower().EndsWith(".xlsx"))
             {
                 hssfworkbook = new XSSFWorkbook(file);
             }
             else if (filePath.Trim().ToLower().EndsWith(".csv"))
             {
                 hssfworkbook = new XSSFWorkbook(file);
             }
            
            
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     #endregion
 }
开发者ID:lxh2014,项目名称:WindowsService,代码行数:29,代码来源:FileManagement.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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