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


C# ExcelQueryFactory.GetWorksheetNames方法代码示例

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


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

示例1: 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

示例2: 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

示例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: 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

示例5: GetWorksheetNames_does_not_include_named_ranges

 //[Test] This test is no longer passing. I believe it has something to do with my computer settings
 public void GetWorksheetNames_does_not_include_named_ranges()
 {
     var excel = new ExcelQueryFactory(_excelFileWithNamedRanges);
     var worksheetNames = excel.GetWorksheetNames();
     Assert.AreEqual(
         "Tabelle1, Tabelle3, WS2",
         string.Join(", ", worksheetNames.ToArray()));
 }
开发者ID:hatalski,项目名称:LinqToExcel,代码行数:9,代码来源:ExcelQueryFactoryTests.cs

示例6: 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

示例7: GetWorksheetNames_returns_worksheet_names

        public void GetWorksheetNames_returns_worksheet_names()
        {
            var excel = new ExcelQueryFactory(_excelFileName);

            var worksheetNames = excel.GetWorksheetNames();
            Assert.AreEqual(
                "ColumnMappings, IMEX Table, More Companies, Null Dates, Range1, Sheet1, TrimSpaces",
                string.Join(", ", worksheetNames.ToArray()));
        }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:9,代码来源:ExcelQueryFactoryTests.cs

示例8: GetAll

 public IEnumerable<Surgery> GetAll()
 {
     var fullPath = Path.Combine(Environment.CurrentDirectory, _csvFilePath);
     var excel = new ExcelQueryFactory(fullPath);
     var excelGetWorksheetNames = excel.GetWorksheetNames();
     var surgeries = (from s in excel.Worksheet<Surgery>()
                      select s).ToList();
     return surgeries;
 }
开发者ID:RazaToosy,项目名称:NhsCommissioningMailer,代码行数:9,代码来源:SurgeriesRepository.cs

示例9: ReadExcelFileByPath

        public List<OneMail> ReadExcelFileByPath(string path)
        {
            int i = 0;
            OneMail mail = new OneMail();
            string[] tmp = null;
            List<OneMail> ret = new List<OneMail>();
            ExcelQueryFactory excel = new ExcelQueryFactory(path);
            int Worksheetcount = excel.GetWorksheetNames().Count();

            for (i = 0; i < Worksheetcount; i++)
            {
                IQueryable<Row> query = from p in excel.Worksheet(i)
                                        select p;
                foreach (Row item in query)
                {
                    if (!string.IsNullOrEmpty(item[0].ToString().Trim()))
                    {
                        if (!string.IsNullOrEmpty(mail.alias))
                        {
                            ret.Add(mail);
                        }
                        mail = new OneMail();
                        tmp = item[2].ToString().Replace(')', ' ').Split('(');
                        mail.alias = item[0].ToString().Trim();
                        mail.TMin = tmp[0].Trim();
                        mail.UT = tmp[1].Trim();

                        /// temporary use
                        mail.MTD = mail.UT;
                        ///

                        mail.SRList = new List<SR>();
                    }
                    else
                    {
                        mail.SRList.Add(new SR(
                            item[1].ToString().Trim(),
                            item[3].ToString().Trim(),
                            Convert.ToInt32(item[2].ToString().Trim()
                            )));
                    }
                }
            }
            if (!string.IsNullOrEmpty(mail.alias))
            {
                ret.Add(mail);
            }
            return ret;
        }
开发者ID:jiabailie,项目名称:self-projects,代码行数:49,代码来源:ReadExcel.cs

示例10: GetNamedRanges

 public void GetNamedRanges()
 {
     var excel = new ExcelQueryFactory(_excelFileWithNamedRanges);
     string sheetName = excel.GetWorksheetNames().First();
     Assert.AreEqual(sheetName, "Tabelle1");
     var namedRanges = excel.GetNamedRanges("NameCell");
     //            ExcelQueryArgs args = new ExcelQueryArgs
     //            {
     //                FileName = excel.FileName,
     //                WorksheetName = "NameCell",
     //                ReadOnly = true
     //            };
     //            var namedRanges = ExcelUtilities.GetNamedRanges(args);
     Assert.AreEqual(
         "NameCell",
         string.Join(", ", namedRanges.ToArray()));
 }
开发者ID:ouyh18,项目名称:LteTools,代码行数:17,代码来源:ExcelQueryFactoryTests.cs

示例11: Execute

        public void Execute()
        {
            _excelQueryFactory = new ExcelQueryFactory(_excelFileName);

            using (_store = new DocumentStore { Url = _ravenUrl })
            {
                _store.Initialize();
                _store.DatabaseCommands.EnsureDatabaseExists(_ravenDatabaseName);

                using (_session = _store.OpenSession(_ravenDatabaseName))
                {
                    foreach (string worksheetName in _excelQueryFactory.GetWorksheetNames())
                        ImportWorksheet(worksheetName);

                    ResetDocumentKeyGenerationToDefault();
                }
            }
        }
开发者ID:efarr,项目名称:ExcelToRavenImporter,代码行数:18,代码来源:ExcelImporter.cs

示例12: WriteDataFromExcelToXML

        public void WriteDataFromExcelToXML()
        {
            XDocument doc = new XDocument();
            doc.Add(new XElement("Store"));

            string pathFile = "../../PriceProductBase.xlsx";
            var excelFile = new ExcelQueryFactory(pathFile);

            foreach (var item in excelFile.GetWorksheetNames())
            {
                var category = new XElement(item);
                List<Row> elements;

                if (item == "Prices")
                {
                    elements = (from a in excelFile.Worksheet(item) where a["КодТовара"] != "" select a).Take(5).ToList();
                }
                else
                {
                    elements = (from a in excelFile.Worksheet(item) select a).Take(5).ToList();
                }

                foreach (var el in elements)
                {
                    XElement element = new XElement("Element");
                    foreach(var itemRow in excelFile.GetColumnNames(item))
                    {
                        XElement data = new XElement(itemRow);
                        data.Value = el[itemRow];
                        element.Add(data);
                    }
                    category.Add(element);
                }

                doc.Root.Add(category);
            }

            excelFile.ReadOnly = true;

            doc.Save("PriceProductBase.xml");
        }
开发者ID:irinalesina,项目名称:ITStepProjects,代码行数:41,代码来源:MainWindow.xaml.cs

示例13: ImportExamFromExcel

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

                excelFile.AddMapping("string prop name","column name");
                //excelFile.AddMapping<PayrollItemDataEntryCustom>(x => x.MonthID, PayrollItemDataEntry.MonthID.ToString());
                excelFile.AddMapping<Exam>(x => x.ExamDate, "ExamDate");
               
                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,代码行数:21,代码来源:ExamManager.cs

示例14: Main

        static void Main(string[] args)
        {
            // Получение информации из Excel документа с именем SampleData.xls
            string pathFile = "PriceProductBase.xlsx";

            var excelFile = new ExcelQueryFactory(pathFile);

            string sheetName = "Orders";

            // Вывод списка листов (Worksheet) в Excel документе  

            var infoOrders = from a in excelFile.Worksheet(sheetName)
                             select a;

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

            foreach (var item in infoOrders)
            {
                string pattern = "{0};{1};{2};{3};{4};{5};{6};";

                // Вывод информации из столбцов OrderDate и Total
                Console.WriteLine(string.Format(pattern, item["Номер заказа"],
                    item["Номер продукта"], item["F3"], 
                    item["F4"], item["F5"], 
                    item["F6"], item["F7"]));
            }


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

            Console.ReadKey();
        }
开发者ID:3A9C,项目名称:ITstep,代码行数:40,代码来源:Program.cs

示例15: LoadWorksheetMetaData

        public void LoadWorksheetMetaData()
        {
            var s = new StatusInfo();

            if (File.Exists(ExcelFilePath))
                try
                {
                    ExcelBook = new ExcelQueryFactory(ExcelFilePath);
                    WorkSheets = new ObservableCollection<string>(ExcelBook.GetWorksheetNames());
                    SelectedWorksheet = WorkSheets.First();
                }
                catch (Exception e)
                {
                    s.ErrorMessage = string.Format("File could not be processed {0}", e.Message);
                }
            else
                s.ErrorMessage = string.Format("File Not Found {0}", ExcelFilePath);

            Status = s;
        }
开发者ID:FrankMedvedik,项目名称:coopcheck,代码行数:20,代码来源:ImportWorksheetViewModel.cs


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