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

C# ExcelQueryFactory类代码示例

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

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



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

示例1: Main

        static void Main(string[] args)
        {
            const string excelPath = "c:/temp/excel/Employees.xlsx";

            var excel = new ExcelQueryFactory(excelPath);

            var employees = from e in excel.Worksheet<Employee>("Employee")
                                   select e;

            Console.WriteLine("All Employees");
            Console.WriteLine("");
            WriteInfo(employees);
            Console.WriteLine("");
            Console.WriteLine("");

            var managers = from e in excel.Worksheet<Employee>("Employee")
                            where e.IsManager
                            select e;

            Console.WriteLine("Managers");
            Console.WriteLine("");
            WriteInfo(managers);
            Console.WriteLine("");
            Console.WriteLine("");

            var regularEmployees = from e in excel.Worksheet<Employee>("Employee")
                           where e.IsManager == false
                           select e;

            Console.WriteLine("Regular Employees");
            Console.WriteLine("");
            WriteInfo(regularEmployees);
            Console.WriteLine("");
            Console.Read();
        }
开发者ID:KennyBu,项目名称:LinqToExcelSpike,代码行数:35,代码来源:Program.cs


示例2: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            if (fileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            var sheet = new ExcelQueryFactory();
            sheet.FileName = fileDialog.FileName;

            var dinvList = sheet.Worksheet<DINV_HDR>(0);

            foreach (var item in dinvList)
            {

            }

            var list = sheet.Worksheet(0).ToList();

            foreach (var item in list)
            {

            }

            foreach (var item in sheet.Worksheet(0))
            {

            }
        }
开发者ID:CarlosAdmin,项目名称:DemoCenter,代码行数:31,代码来源:Form1.cs


示例3: GetProductsFromFile

        public IEnumerable<Product> GetProductsFromFile(string filename)
        {
            var excel = new ExcelQueryFactory(filename);
            var worksheetNames = excel.GetWorksheetNames().ToArray();
            //
            //Mapping
            //
            for (int i = 0; i < worksheetNames.Length; i++)
            {
                var columnNames = excel.GetColumnNames(worksheetNames[i]);
                var titleRow = FindTitleRow(excel.WorksheetNoHeader(worksheetNames[i]));

                var codeIndex = 0;
                var priceIndex = GetColumnIndex(titleRow, "Price");

                bool skip = true;
                foreach (var product in excel.WorksheetNoHeader(worksheetNames[i])
                    .Where(x => x[codeIndex] != ""))
                {
                    if (skip)
                    {
                        skip = product[codeIndex].ToString().Trim() != "No.:";
                        continue;
                    }
                    yield return
                        new Product
                        {
                            Code = product[codeIndex].ToString().Trim(),
                            Price = product[priceIndex].Cast<decimal>()
                        };
                }
            }
        }
开发者ID:swimtver,项目名称:Owin,代码行数:33,代码来源:ExcelReader.cs


示例4: s

 public void s()
 {
     _repo = new ExcelQueryFactory { FileName = _excelFileName };
     _repo.AddMapping<ChineseNameColumn>(x => x.ChineseColumn, "第一列");
     _repo.AddMapping<ChineseNameColumn>(x => x.DoubleColumn, "第二列(复杂的:浮点-》");
     _repo.AddMapping<ChineseNameColumn>(x => x.ThirdColumn, "第3列:\"待引号的\"");
 }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:7,代码来源:ChineseNameColumnTest.cs


示例5: btnSelectFile_Click

        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.CurrentDirectory;
            // openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Excel(*.xlsx)|*.xlsx|Excel 2000-2003(*.xls)|*.xls|CSV(*.csv)|*.csv|所有文件(*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                string FileName = openFileDialog.FileName;

                var execelfile = new ExcelQueryFactory(FileName);

                this.txtContact.Text = FileName;
                this.txtContact.Enabled = false;

                List<string> sheetNames=  execelfile.GetWorksheetNames().ToList();
               
                
                //星级信息
                List<Row> agentStar = execelfile.Worksheet(0).ToList(); ;

                if (agentStar != null && agentStar.Count > 0)
                {
                   
                    this.btnImport.Enabled = true;
                    dgAgentStar.Rows.Clear();
                    dgAgentStar.Columns.Clear();
                    foreach (String coloumn in agentStar[0].ColumnNames)
                    {
                        this.dgAgentStar.Columns.Add(coloumn, coloumn);
                    }

                    for (int i = 0; i < agentStar.Count; i++)
                    {
                        if (String.IsNullOrEmpty(agentStar[i][0]))
                        {
                            continue;
                        }
                        dgAgentStar.Rows.Add();
                        DataGridViewRow row = dgAgentStar.Rows[i];
                        foreach (String coloumn in agentStar[0].ColumnNames)
                        {
                            row.Cells[coloumn].Value = agentStar[i][coloumn];
                        }

                    }
                }


                dgAgentStar.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
                dgAgentStar.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

                dgAgentStar.AutoResizeColumns();

               

                Cursor.Current = Cursors.Default;
            }
        }
开发者ID:ZhouAnPing,项目名称:Mail,代码行数:60,代码来源:frmAgentStarImport.cs


示例6: GetGamesFromPuzzleGameWorksheet

        private static List<PuzzleGame> GetGamesFromPuzzleGameWorksheet(ExcelQueryFactory excel, int puzzleSubGroupId)
        {
            //Get all games for a sub group
            var games = from c in excel.Worksheet("PuzzleGame")
                        select new
                                   {
                                       PuzzleGameId = c["PuzzleGameId"].Cast<int>(),
                                       PuzzleSubGroupId = c["PuzzleSubGroupId"].Cast<int>(),
                                       Word = c["Word"].Cast<string>(),
                                       Hint = c["Hint"].Cast<string>()
                                   };

            var gamelist = games.ToList();
            var grouped = from c in gamelist
                          where c.PuzzleSubGroupId == puzzleSubGroupId
                          group c by c.PuzzleGameId
                          into g
                          select new {PuzzleGameId = g.Key, Games = g};

            var puzzleGames = new List<PuzzleGame>();
            foreach (var gamesSet in grouped)
            {
                var puzzleGame = new PuzzleGame()
                                     {PuzzleGameId = gamesSet.PuzzleGameId, Words = new Dictionary<string, string>()};
                foreach (var game in gamesSet.Games)
                {
                    puzzleGame.Words.Add(game.Word, game.Hint);
                    Console.WriteLine(game.Word);
                }
                puzzleGames.Add(puzzleGame);
            }

            return puzzleGames;
        }
开发者ID:abdulbaruwa,项目名称:CrossSharp,代码行数:34,代码来源:Program.cs


示例7: ImportStudentFromExcel

       public bool ImportStudentFromExcel(string filePath)
       {
           bool result = false;
           if (!string.IsNullOrEmpty(filePath))
           {
               var excelFile = new ExcelQueryFactory(filePath);
               List<string> sheetnames = excelFile.GetWorksheetNames().ToList();

               //excelFile.AddMapping<PayrollItemDataEntryCustom>(x => x.Remarks, PayrollItemDataEntry.Remarks.ToString());
               //excelFile.AddMapping<PayrollItemDataEntryCustom>(x => x.filePath, PayrollItemDataEntry.filePath.ToString());
               //excelFile.AddMapping<PayrollItemDataEntryCustom>(x => x.sheetNames, "tstSheet1");//PayrollItemDataEntry.sheetNames.ToString()

               excelFile.AddMapping<Student>(x => x.SID, "SID");
               excelFile.AddMapping<Student>(x => x.Name,"Name");
               excelFile.AddMapping<Student>(x => x.Minor, "Minor");
               excelFile.AddMapping<Student>(x => x.Major, "Major");
               excelFile.AddMapping<Student>(x => x.Division, "Division"); 

               excelFile.StrictMapping = StrictMappingType.ClassStrict;
               excelFile.TrimSpaces = TrimSpacesType.Both;
               excelFile.ReadOnly = true;

               var AllExcellData = (from ExcelData in excelFile.Worksheet(0)
                                    select ExcelData).ToList();
           }
           return result;
       }
开发者ID:elhaddad1,项目名称:universityofscience,代码行数:27,代码来源:StudentManager.cs


示例8: btnUpload_FileSelected

 protected void btnUpload_FileSelected(object sender, EventArgs e)
 {
     if (btnUpload.HasFile)
     {
         string fileName = btnUpload.ShortFileName;
         if (!fileName.EndsWith(".xlsx"))
         {
             Alert.Show("只支持xlsx文件类型!");
             return;
         }
         string path = ConfigHelper.GetStringProperty("DataFilePath", @"D:\root\Int\data\") + "tmp\\" + fileName;
         btnUpload.SaveAs(path);
         var execelfile = new ExcelQueryFactory(path);
         execelfile.AddMapping<UserInfo>(x => x.Code, "登录帐号");
         execelfile.AddMapping<UserInfo>(x => x.Name, "姓名");
         execelfile.AddMapping<UserInfo>(x => x.NameEn, "英文名");
         execelfile.AddMapping<UserInfo>(x => x.Departments, "部门");
         execelfile.AddMapping<UserInfo>(x => x.JobName, "职位");
         execelfile.AddMapping<UserInfo>(x => x.Phone, "电话");
         execelfile.AddMapping<UserInfo>(x => x.Email, "电子邮箱");
         execelfile.AddMapping<UserInfo>(x => x.LeaderCode, "上级领导");
         var list = execelfile.Worksheet<UserInfo>(0).ToList();
         Import(list);
         this.userGrid.PageIndex = 0;
         GridBind();
         Alert.Show("上传成功");
     }
 }
开发者ID:macchicken,项目名称:MobileWorkManagement,代码行数:28,代码来源:UserList.aspx.cs


示例9: ReconciliationUpload

 public ActionResult ReconciliationUpload(Guid fileid)
 {
     var model = new List<UploadReconciliationModel>();
     var uploadFilePath = ConfigurationManager.AppSettings["UploadFilePath"];
     if (!Directory.Exists(uploadFilePath))
     {
         Directory.CreateDirectory(uploadFilePath);
     }
     var fileNamePrefix = fileid.ToString();
     var file = System.Web.HttpContext.Current.Request.Files[0];
     if (file.ContentLength > 0)
     {
         var fileName = Path.GetFileName(file.FileName);
         //var fileExtension = Path.GetExtension(fileName);
         //var newFileName = fileNamePrefix + fileExtension;
         //var fileFullPath = uploadFilePath + newFileName;
         var fileFullPath = uploadFilePath + fileNamePrefix;
         try
         {
             file.SaveAs(fileFullPath);
             //return RedirectToAction("Reconciliation", new { filePath = uploadFilePath });
             var excel = new ExcelQueryFactory(fileFullPath);
             model = excel.Worksheet<UploadReconciliationModel>(0).ToList();
         }
         catch (Exception)
         {
             System.IO.File.Delete(fileFullPath);
         }
     }
     return View(model.ToArray());
 }
开发者ID:xiaoxiao95888,项目名称:Nicole,代码行数:31,代码来源:FinanceController.cs


示例10: Index

        public ActionResult Index()
        {
            foreach (string upload in Request.Files)
            {
            //    if (!Request.Files[upload]) continue;
                string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/";
                string filename = Path.GetFileName(Request.Files[upload].FileName);
                string pathToExcelFile = Path.Combine(path, filename);

                string sheetName = "Sheet1";

                Request.Files[upload].SaveAs(pathToExcelFile);

                var excelFile = new ExcelQueryFactory(pathToExcelFile);
                var data = from a in excelFile.Worksheet<ExcelData>(sheetName) select a;

                using (var ctx = new Context())
                {
                    foreach (var a in data)
                    {
                        ctx.ExcelData.Add(a);
                        //Console.WriteLine(string.Format(artistInfo, a.Account, a.Account));
                    }

                    ctx.SaveChanges();
                }

            }

            return View();
        }
开发者ID:jituce,项目名称:Testrepo,代码行数:31,代码来源:HomeController.cs


示例11: Import

        public List<string> Import(string path, IEnumerable<string> regions)
        {
            var factory = new ExcelQueryFactory {FileName = path};
            var message = (from region in regions
                let stats = (from c in factory.Worksheet<CdmaRegionStatExcel>(region)
                    where c.StatDate > DateTime.Today.AddDays(-30) && c.StatDate <= DateTime.Today
                    select c).ToList()
                let count = _regionStatRepository.Import<ICdmaRegionStatRepository, CdmaRegionStat, CdmaRegionStatExcel>(stats)
                select "完成导入区域:'" + region + "'的日常指标导入" + count + "条").ToList();

            var topDrops = (from c in factory.Worksheet<TopDrop2GCellExcel>(TopDrop2GCellExcel.SheetName)
                            select c).ToList();
            var drops = _top2GRepository.Import<ITopDrop2GCellRepository, TopDrop2GCell, TopDrop2GCellExcel>(topDrops);
            message.Add("完成TOP掉话小区导入" + drops + "个");

            var topConnections = (from c in factory.Worksheet<TopConnection3GCellExcel>(TopConnection3GCellExcel.SheetName)
                                  select c).ToList();
            var connections =
                _top3GRepository.Import<ITopConnection3GRepository, TopConnection3GCell, TopConnection3GCellExcel>(
                    topConnections);
            message.Add("完成TOP连接小区导入" + connections + "个");

            var topConnection2Gs = (from c in factory.Worksheet<TopConnection2GExcel>(TopConnection2GExcel.SheetName)
                select c).ToList();
            var connection2Gs =
                _topConnection2GRepository.Import<ITopConnection2GRepository, TopConnection2GCell, TopConnection2GExcel>
                    (topConnection2Gs);
            message.Add("完成TOP呼建小区导入" + connection2Gs + "个");

            return message;
        }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:31,代码来源:KpiImportService.cs


示例12: Import

        public static IEnumerable<Route> Import(string filename, ClimbrContext context)
        {
            var excel = new ExcelQueryFactory(filename);
            var sheetRoutes = excel.Worksheet<SheetRoute>()
                .Where(r => r.Grade != "#REF!" && r.Grade != null)
                .ToList();

            for (int i = 1; i < sheetRoutes.Count; i++)
            {
                if (sheetRoutes[i].Line == null || sheetRoutes[i].Line == "#REF!")
                {
                    sheetRoutes[i].Line = sheetRoutes[i - 1].Line;
                }
            }

            var routes = sheetRoutes.Select(
                sr => new Route
                {
                    Color = context.Colors.Single(c => c.Name.Equals(sr.Colour, StringComparison.InvariantCultureIgnoreCase)),
                    Grade = context.Grades.Single(g => g.Name.Equals(sr.Grade, StringComparison.InvariantCultureIgnoreCase)),
                    Name = sr.Line
                })
                .ToList();

            return routes;
        }
开发者ID:pfarrel,项目名称:climbr,代码行数:26,代码来源:AwesomeImporter.cs


示例13: Main

        static void Main(string[] args)
        {

            // Получение информации из Excel документа с именем SampleData.xls
            string pathFile = "SampleData.xls";
                      
            var excelFile = new ExcelQueryFactory(pathFile);

            // Вывод списка листов (Worksheet) в Excel документе  
            foreach( var item in excelFile.GetWorksheetNames())
            {
                Console.Write(item+" ");
            }
            Console.Write("\n");

            foreach (var item in excelFile.GetWorksheetNames())
            {
                Console.Write(item + ":");
                foreach (var itemRow in excelFile.GetColumnNames(item))
                {
                    Console.Write(itemRow + " ");
                }
                Console.Write("\n");
            }


            // установка документа "только для чтения"
            excelFile.ReadOnly = true;

            Console.ReadKey();
        }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:31,代码来源:Program.cs


示例14: Read

 public static IList<CollectionImportModel> Read(string fileName)
 {
     var data = new ExcelQueryFactory(fileName);
     SetupColumnMapping(data);
     SetupTransforms(data);
     return data.Worksheet<CollectionImportModel>().ToList();
 }
开发者ID:jelgee-daptiv,项目名称:MTGO_Automated_Trader,代码行数:7,代码来源:CollectionImporter.cs


示例15: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();
            if (DialogResult.OK == fdlg.ShowDialog())
            {
                var excel = new ExcelQueryFactory(fdlg.FileName);
                var indianaCompanies = from c in excel.Worksheet("Sheet1")
                                       select c;
                int ix = 0;
                int il = 0;
                foreach (var item in indianaCompanies)
                {
                    TblInfor newInfo = new TblInfor();

                    string content = "<b>" + item[1].ToString().Trim() + "</b> <br />"
                                    + "" + item[10].ToString().Trim()
                                    + "<br>Khu vực: " + item[9].ToString().Trim()
                                   + "<br>ĐC: " + item[4].ToString().Trim()
                                   + "<br> Số Phòng: " + item[6].ToString().Trim()
                                   + "<br> ĐT: " + item[2].ToString().Trim() + " - FAX: " + item[3].ToString().Trim()
                                   + "<br> Email: " + item[5].ToString().Trim()
                                    + "<br> Chủ đầu tư: " + item[7].ToString().Trim()
                                   + "<br>Giám đốc: " + item[8].ToString().Trim();

                    string tag = "Khách sạn, khach san, ks, " + item[11].ToString().Trim() + ", " + item[2].ToString().Trim();

                    newInfo.CreateDate = DateTime.Now;
                    newInfo.CreateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");
                    newInfo.ID = Guid.NewGuid();
                    newInfo.Category = Categories.KhachSan;
                    newInfo.Location = item[9].ToString().Trim();
                    newInfo.InfoContent = HtmlRemoval.StripTagsRegexCompiled(content);
                    newInfo.InfoContentHtml = content;
                    newInfo.InfoTag = tag;
                    newInfo.InfoTitle = item[1].ToString().Trim() + " " + item[9].ToString().Trim();
                    newInfo.InfoType = InformationType.NoLimit;
                    newInfo.Status = InformationStatus.Approved;

                    newInfo.UpdateDate = DateTime.Now;
                    newInfo.UpdateUserID = Guid.Parse("b0b6997c-282b-4aff-b286-b0820cdb0100");

                    try
                    {
                        BBLInfo b = new BBLInfo();
                        b.InsertOrUpdate(newInfo);

                        ix++;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("E - > " + ex.Message);
                        // DevExpress.XtraEditors.XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, this.FindForm(), ex.Message, "Có sự cố", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        il++;
                    }
                }

                Console.WriteLine(ix + " | " + il);
            }
        }
开发者ID:sonartez,项目名称:TTXTDL-HoiAn,代码行数:59,代码来源:Form1.cs


示例16: GetExcelRowEnumerableFromExcelFile

 private IEnumerable<ExcelRow> GetExcelRowEnumerableFromExcelFile(string filePath)
 {
     var excel = new ExcelQueryFactory();
     excel.FileName = filePath;
     IEnumerable<ExcelRow> query = from e in excel.Worksheet<ExcelRow>(0)
                                   select e;
     return query;
 }
开发者ID:bigfont,项目名称:OrderSystem,代码行数:8,代码来源:HomeController.cs


示例17: ManipuladorExcel

 public ManipuladorExcel(string nombreArchivo)
 {
     _excel = new ExcelQueryFactory(nombreArchivo)
     {
         ReadOnly = true,
         UsePersistentConnection = true
     };
 }
开发者ID:smezae,项目名称:ejemplo-LinqToExcel,代码行数:8,代码来源:ManipuladorExcel.cs


示例18: Main

        static void Main(string[] args)
        {
            var file = @"NamedRange.xlsb";
            var excel = new ExcelQueryFactory(file);

            var unique = excel.NamedRange("NamedRangeUniqueCell");
            var multiple = excel.NamedRange("NamedRangeMultipleCells");
        }
开发者ID:achvaicer,项目名称:LinqToExcelNamedRangeTest,代码行数:8,代码来源:Program.cs


示例19: GetWorksheetNames_does_not_include_builtin_worksheets

 public void GetWorksheetNames_does_not_include_builtin_worksheets()
 {
     var excel = new ExcelQueryFactory(_excelFileWithBuiltinWorksheets);
     var worksheetNames = excel.GetWorksheetNames();
     Assert.AreEqual(
         "AutoFiltered, ColumnMappings, MoreCompanies, NullCells, Paul's Worksheet, Sheet1",
         string.Join(", ", worksheetNames.ToArray()));
 }
开发者ID:hatalski,项目名称:LinqToExcel,代码行数:8,代码来源:ExcelQueryFactoryTests.cs


示例20: bad_column_mapping_in_where_clause

 public void bad_column_mapping_in_where_clause()
 {
     var excel = new ExcelQueryFactory(_excelFileName);
     excel.AddMapping<CompanyWithCity>(x => x.City, "Town");
     var list = (from x in excel.Worksheet<CompanyWithCity>("Sheet1")
                 where x.City == "Omaha"
                 select x).ToList();
 }
开发者ID:CodeFork,项目名称:LinqToExcel,代码行数:8,代码来源:InvalidColumnNamesUsed.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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