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


C# Workbook.Open方法代码示例

本文整理汇总了C#中Workbook.Open方法的典型用法代码示例。如果您正苦于以下问题:C# Workbook.Open方法的具体用法?C# Workbook.Open怎么用?C# Workbook.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workbook的用法示例。


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

示例1: CreateCourseCalendar

        private void CreateCourseCalendar()
        {
            try
            {
                mbook = new Workbook();
                mbook.Open(txtFilename.Text);

                int Progress = 0;
                int MaxDataRow = mbook.Worksheets[0].Cells.MaxDataRow;

                List<ClassBusyDateSource> ClassBusySources = new List<ClassBusyDateSource>();

                for (int i = 1; i <= MaxDataRow; i++)
                {
                    Progress = (int)((double)i / MaxDataRow * 100);
                    ClassBusyDateSource vClassBusySource = new ClassBusyDateSource(mbook.Worksheets[0].Cells, i);
                    ClassBusySources.Add(vClassBusySource);
                }

                worker.RunWorkerAsync(ClassBusySources);
            }
            catch (Exception ve)
            {
                MessageBox.Show(ve.Message);
            }
        }
开发者ID:KunHsiang,项目名称:ischedulePlus,代码行数:26,代码来源:frmCreateClassBusyCalendar.cs

示例2: Import

        public bool Import(string model_file_path)
        {
            Workbook workBook = new Workbook();
            workBook.Open(model_file_path);

            foreach (Worksheet workSheet in workBook.Worksheets)
            {
                Cells cls = workSheet.Cells;
                string baseType = cls[0, 1].Value.ToString();
                string className = cls[1, 1].Value.ToString();

                switch (baseType)
                {
                    case "Named object:":
                        ImportNamedObjects(cls, className);
                        break;
                    case "Revisioned object:":
                        ImportRevisionedObjects(cls, className);
                        break;
                }
            }

            workBook.Save(model_file_path);
            return true;
        }
开发者ID:Eric-Guo,项目名称:uo-mes,代码行数:25,代码来源:ExcelModeler.cs

示例3: Main

        static void Main(string[] args)
        {
            //Instantiate a new Workbook.
            Workbook workbook = new Workbook();

            //Specify the template excel file path.
            string myPath = "Book1.xls";

            //Open the excel file.
            workbook.Open(myPath);

            //Get the range of cells i.e.., A1:C1.
            Aspose.Cells.Range rng1 = workbook.Worksheets[0].Cells.CreateRange("A1", "C1");

            //Merge the cells.
            rng1.Merge();

            Cells rng = workbook.Worksheets[0].Cells;

            //UnMerge the cell.
            rng.UnMerge(0, 0, 1, 3);

            //Save the file.
            workbook.Save("Book1.xls");
        
        }
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:26,代码来源:Program.cs

示例4: ExportDataTableAsExcel

 /// <summary>
 /// 导出DataTable数据为Excel文件
 /// </summary>
 /// <param name="model">Excel模板</param>
 public void ExportDataTableAsExcel(ExcelModel model)
 {
     bool existsModelFile = false;
     if (!string.IsNullOrEmpty(model.ModelFileFullName))
     {
         //有赋值模板文件路径,判断模板文件是否存在,不存在则抛异常
         existsModelFile = File.Exists(model.ModelFileFullName);
         if (!existsModelFile)
         {
             throw new FileNotFoundException("Excel Model File Not Exists");
         }
     }
     int totalCount = model.DataSource.Rows.Count;
     int pages = (int)Math.Ceiling(totalCount * 1.0 / model.PageSize); //计算需要的文件数
     List<Workbook> excelList = new List<Workbook>();
     for (int p = 0; p < pages; p++)
     {
         Workbook excel = new Workbook();
         if (existsModelFile)
         {
             //存在模板文件则使用模板文件
             excel.Open(model.ModelFileFullName);
         }
         Worksheet sheet = excel.Worksheets[0];
         if (!existsModelFile)
         {
             //不存在模板文件则设置表头
             foreach (ExcelColumnModel column in model.ColumnModels)
             {
                 sheet.Cells[column.Column + 1].PutValue(column.Header);
             }
         }
         int st = p * model.PageSize;
         int ed = model.PageSize * (p + 1);
         if (ed > totalCount)
         {
             ed = totalCount;
         }
         int row = model.FirstRowIndex;
         for (int i = st; i < ed; i++)
         {
             DataRow dr = model.DataSource.Rows[i];
             foreach (ExcelColumnModel column in model.ColumnModels)
             {
                 sheet.Cells[column.Column + row].PutValue(dr[column.Field]);
             }
             row++;
         }
         excelList.Add(excel);
     }
     //save file
     for (int i = 0; i < excelList.Count; i++)
     {
         string fname = string.Format("{0}/{1}{2}.xls", Path.GetDirectoryName(model.SaveFileFullName), Path.GetFileNameWithoutExtension(model.SaveFileFullName), i);
         excelList[i].Save(fname);
     }
 }
开发者ID:jeephalin,项目名称:dotnet,代码行数:61,代码来源:ExportHelper.cs

示例5: buttonPhone_Click

        private void buttonPhone_Click(object sender, EventArgs e)
        {
            //string result = IPLocationUtil.GetIPLocation("15.203.233.86");
            Workbook currentWorkbook = new Workbook();
            currentWorkbook.Open("Trades.xls");

            Worksheet sheet = currentWorkbook.Worksheets[0];
            TradeIpHandler.ExtractMobilePhone(sheet);
            currentWorkbook.Save("Trades.xls");
        }
开发者ID:daizhen,项目名称:Misc_Utils,代码行数:10,代码来源:Form1.cs

示例6: AsposeCell

 public AsposeCell(string fullName)
 {
     _workbook = new Workbook();
     _workbook.Open(fullName);
     _worksheets = new Dictionary<string, Worksheet>();
     foreach (Worksheet worksheet in _workbook.Worksheets)
     {
         _worksheets.Add(worksheet.Name, worksheet);
     }
     _currentWorksheet = _workbook.Worksheets[0];
 }
开发者ID:hoshealee,项目名称:balabalaDemo,代码行数:11,代码来源:AsposeCell.cs

示例7: Submit_Click

        protected void Submit_Click(object sender, EventArgs e)
        {
            // open and read excel file
            var workbook = new Workbook();
            var fileType = FileFormatType.CSV;
            if(Path.GetExtension(ImportFile.FileName) == ".xlsx") fileType = FileFormatType.Excel2007Xlsx;
            else if(Path.GetExtension(ImportFile.FileName) == ".xls") fileType = FileFormatType.Excel2003;
            else if(Path.GetExtension(ImportFile.FileName) == ".csv") fileType = FileFormatType.CSV;
            else
            {
                ErrorMessage.Text = "Incorrect file type. We need an excel file!";
                return;
            }

            workbook.Open(ImportFile.FileContent, fileType);
            var sheet = workbook.Worksheets[0];

            var loadProfileRepository = IoC.Resolve<IRepository<Model.Simulation.LoadProfile>>();
            var userRepository = IoC.Resolve<IRepository<User>>();
            using (var tran = UnitOfWork.Current.BeginTransaction())
            {
                var loadProfile = new Model.Simulation.LoadProfile
                                      {
                                          Name = Name.Text,
                                          Description = Description.Text,
                                          AddedBy = userRepository.Load(new Guid(User.Identity.Name))
                                      };

                for (var row = 1; row <= sheet.Cells.MaxRow; row++ )
                {
                    loadProfile.Data.Add(new LoadProfileData
                                             {
                                                 StartTime =
                                                     DateTime.Parse(sheet.Cells[row, 0].StringValue + " " +
                                                                    sheet.Cells[row, 1].StringValue),
                                                 EndTime =
                                                     DateTime.Parse(sheet.Cells[row, 2].StringValue + " " +
                                                                    sheet.Cells[row, 3].StringValue),
                                                 Consumption = sheet.Cells[row, 4].DoubleValue
                                             });
                }

                loadProfileRepository.Save(loadProfile);

                tran.Commit();
                UnitOfWork.Current.TransactionalFlush();

                SuccessMessage.Text = "Load Profile imported successfully.";
            }

            ClearFields();
        }
开发者ID:enct,项目名称:simulatortool,代码行数:52,代码来源:Import.aspx.cs

示例8: RunConvert

        private static void RunConvert(string srcFileName, string dstFileName)
        {
            //Open Excel Workbook using Aspose.Cells.
            Workbook workbook = new Workbook();
            workbook.Open(srcFileName);

            //Convert workbook to Word document
            ConverterXls2Doc converter = new ConverterXls2Doc();
            Document doc = converter.Convert(workbook);

            // Save using Aspose.Words.
            doc.Save(dstFileName);
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:13,代码来源:MainForm.cs

示例9: buttonProcess_Click

        private void buttonProcess_Click(object sender, EventArgs e)
        {
            Workbook currentWorkbook = new Workbook();
            currentWorkbook.Open("Trades.xls");
            TradeIpHandler.GetIpLocationList(currentWorkbook, "Trades_result.xls");
            //Worksheet sheet = currentWorkbook.Worksheets[0];

            //List<string> ipAddressList = TradeIpHandler.GetAllIp(sheet);
            //List<string> ipLocationList = TradeIpHandler.GetIpLocationList(ipAddressList);
            //for(int i =0;i<ipLocationList.Count;i++)
            //{
            //    sheet.Cells[i + 1, 0].PutValue(ipLocationList[i]);
            //}
        }
开发者ID:daizhen,项目名称:Misc_Utils,代码行数:14,代码来源:Form1.cs

示例10: DataTableInsertToExcel

 public static bool DataTableInsertToExcel(DataTable datatable, ArrayList colNameList, string fromfile, out string error, int beginRow, int beginColumn)
 {
     error = "";
     if (datatable == null)
     {
         error = "DataTableToExcel:datatable 为空";
         return false;
     }
     Workbook workbook = new Workbook();
     workbook.Open(fromfile);
     Aspose.Cells.Cells cells = workbook.get_Worksheets().get_Item(0).get_Cells();
     int num = 0;
     foreach (DataRow row in datatable.Rows)
     {
         num++;
         try
         {
             cells.InsertRow(beginRow);
             for (int i = 0; i < colNameList.Count; i++)
             {
                 string str = colNameList[i].ToString();
                 int num3 = 0;
                 while (num3 < datatable.Columns.Count)
                 {
                     if (str == datatable.Columns[num3].ColumnName)
                     {
                         goto Label_00C4;
                     }
                     num3++;
                 }
                 continue;
             Label_00C4:
                 object obj1 = row[datatable.Columns[num3].ColumnName];
                 cells.get_Item(beginRow, beginColumn + i).PutValue(row[datatable.Columns[num3].ColumnName]);
             }
             continue;
         }
         catch (Exception exception)
         {
             error = error + " DataTableInsertToExcel: " + exception.Message;
             continue;
         }
     }
     workbook.Save(fromfile);
     return true;
 }
开发者ID:windygu,项目名称:asxinyunet,代码行数:46,代码来源:AsposeExcelTools.cs

示例11: Export

        public static void Export(List<RequestItem> items, string fileName, int month)
        {
            string sheetName = month + "月";
            Workbook currentWorkbook = new Workbook();
            currentWorkbook.Open(fileName);
            Worksheet sheet = currentWorkbook.Worksheets[sheetName];
            if (sheet == null)
            {
                currentWorkbook.Worksheets.Add(sheetName);
                sheet = currentWorkbook.Worksheets[sheetName];
            }
            sheet.Cells[0, 0].PutValue("原名称");
            sheet.Cells[0, 1].PutValue("文件名");
            sheet.Cells[0, 2].PutValue("标准名称");
            sheet.Cells[0, 3].PutValue("编号");
            sheet.Cells[0, 4].PutValue("钱");

            for (int i = 0; i < items.Count; i++)
            {
                sheet.Cells[i + 1, 0].PutValue(items[i].RawName);
                sheet.Cells[i + 1, 1].PutValue(items[i].FileName);
                sheet.Cells[i + 1, 2].PutValue(items[i].FullName);
                sheet.Cells[i + 1, 3].PutValue(items[i].SerialNum);
                sheet.Cells[i + 1, 4].PutValue(items[i].Money);

            }

            //Add items to summary sheet

            Worksheet sheetSummary = currentWorkbook.Worksheets["Summary"];
            for (int i = 1; i <= 127; i++)
            {
                var list = items.FindAll(p => p.SerialNum == sheetSummary.Cells[i, 0].StringValue);
                double resultValue =Sum(list);
                if (resultValue != 0)
                {
                    sheetSummary.Cells[i, month + 1].PutValue(resultValue);
                }
                else
                {
                    sheetSummary.Cells[i, month + 1].PutValue(null);
                }
            }
            currentWorkbook.Save(fileName);
        }
开发者ID:daizhen,项目名称:Misc_Utils,代码行数:45,代码来源:GroupHandler.cs

示例12: Main

        static void Main(string[] args)
        {
            //Instantiate a new Workbook.
            Workbook workbook = new Workbook();

            //Specify the template Excel file path.
            string myPath = "Book1.xls";

            //Open the Excel file.
            workbook.Open(myPath);

            //Get the first sheet.
            Aspose.Cells.Worksheet objSheet = workbook.Worksheets["Sheet1"];

            findNow(objSheet, "test");

            workbook.Save(myPath);
        }
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:18,代码来源:Program.cs

示例13: CleanToInsertStatus

        public bool CleanToInsertStatus(string model_file_path)
        {
            Workbook workBook = new Workbook();
            workBook.Open(model_file_path);

            foreach (Worksheet workSheet in workBook.Worksheets)
            {
                Cells cls = workSheet.Cells;
                string baseType = cls[0, 1].Value.ToString();

                switch (baseType)
                {
                    case "Named object:":
                    case "Revisioned object:":
                        CleanExecuteAndCompleteMsg(cls);
                        break;
                }
            }

            workBook.Save(model_file_path);
            return true;
        }
开发者ID:Eric-Guo,项目名称:uo-mes,代码行数:22,代码来源:ExcelModeler.cs

示例14: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            Workbook currentWorkbook = new Workbook();
            currentWorkbook.Open("2015_New.xls");

            int[] monthList = new int[] { 1, 2, 3, 4, 5, 6, 7, 8,9,10,11,12 };

            //string folder = @"C:\Users\dz\Downloads\凭证购买2015\{0}月凭证领用";
            //string resultFileName = "2015.xls";

            //int[] monthList = new int[] { 1, 2, 3, 4, 5, 6, 7, 8,9,10,11,12 };
            foreach (int month in monthList)
            {
                Worksheet sheet = currentWorkbook.Worksheets[month + "月"];
                var items = GroupHandler.LoadMonthData(sheet);
                GroupHandler.Export(items, "2015_New2.xls", month);
            }
            //if (GetherData(textBoxDir.Text, textBoxDestDir.Text))
            //{
            //	MessageBox.Show("操作成功");
            //}
        }
开发者ID:daizhen,项目名称:Misc_Utils,代码行数:22,代码来源:MainForm.cs

示例15: ExcelHelper

        public ExcelHelper(string fileName)
        {
            _FileName = fileName;
            
            _Report = new Workbook();
            _Report.Open(new MemoryStream(Properties.Resources.中投區積分比序_Template));
            _OutSheet = _Report.Worksheets[Global.Title];

            // 先儲存Style
            GetExcelStyle();

            _OutCells = _OutSheet.Cells;
            _DetailCells = null;

            if (Global.IsDebug == true)
            {
                _DetailSheet = _Report.Worksheets[_Report.Worksheets.Add()];
                _DetailSheet.Name = "Detail Sheet";

                _DetailCells = _DetailSheet.Cells;
                _DetailRowIndex = 0;
            }
        }
开发者ID:redolin,项目名称:K12.Report.ZhuengtouPointsCompetition,代码行数:23,代码来源:ExcelHelper.cs


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