linq-to-excel

LinqToExcel blank rows

假装没事ソ 提交于 2020-01-14 22:47:51
问题 I am using LinqToExcel to easily import Excel data into SQL Server. var fileName = ConfigurationManager.AppSettings["ExcelFileLocation"]; var excel = new ExcelQueryFactory(fileName); var employees = excel.Worksheet<Employee>().ToList(); Everything's fine, there is only 1 problem, the fields mapped exactly to the database table fields, and in the database they are NOT NULL. Having said that, if you look at this screenshot of Excel file, some rows below row 3 are actually not empty. There are

Importing data with LinqToExcel

早过忘川 提交于 2019-12-24 11:57:17
问题 I have an XLSX spreadsheet that I am trying to import into a IList(of FinancialResults) collection using VB.NET. The spreadsheet is in the below format where I need to map the cells from the appropriate columns into a class. Spreadsheet Model Public Class FinancialResults Friend Property MonthBudget As Single Friend Property MonthActual As Single Friend Property YearToDateBudget As Single Friend Property YearToDateActual As Single Friend Property FullYearForcastBudget As Single Friend

Read an Excel spreadsheet in memory

China☆狼群 提交于 2019-12-23 06:57:54
问题 How can I read an Excel spreadsheet that was just posted to my server? I searched for something but I only found how to read an Excel spreadsheet with the file name path which is not my case. I need something like that: public ActionResult Import(HttpPostedFileBase file) { var excel = new ExcelQueryFactory(file); //using linq to excel } 回答1: I was running into your same issue but I didn't want to switch to a paid service so this is what I did. public class DataImportHelper : IDisposable {

LinqToExcel Not Parsing Date

只愿长相守 提交于 2019-12-23 04:39:27
问题 I am working with a client to import a rather larger Excel file (over 37K rows) into a custom system and utilizing the excellent LinqToExcel library to do so. While reading all of the data in, I noticed it was breaking on records about 80% in and dug a little further. The reason it fails is the majority of records (with associated dates ranging 2011 - 2015) are normal, e.g. 1/3/2015 , however starting in 2016, the structure changes to look like this: '1/4/2016 (note the "tick" at the

LinqToExcel: Distinct values in excel column

时光总嘲笑我的痴心妄想 提交于 2019-12-23 03:13:06
问题 This might be a very simple thing for you gurus, but I'm not familiar with C#4 and INTEROP. Therefore, I'm stumped. Here's my problem. I have a excel column that has duplicate data and I want to trim it down to only unique values. Here's what the data looks like: ColA ColB 10 Adam 12 Jane 14 Adam 18 Adam 20 Eve So, in the end I just want unique names from ColB: Adam Jane Eve I know that I can do this by getting all those values into a List and then adding the Distinct functionality to it. But

How do i use LinqToExcel to get sheet names of an excel file

情到浓时终转凉″ 提交于 2019-12-12 11:44:27
问题 I am using LinqToExcel and i want to be able to get the names of all sheets in an excel file and compare it with an input from my html form such that when the input does not match any of the names on the excel sheet the system will throw an exception. How do i go about using LinqToExcel to do this 回答1: The documentation says: The GetWorksheetNames() method can be used to retrieve the list of worksheet names in a spreadsheet. var excel = new ExcelQueryFactory("excelFileName"); var

How to retrieve column names from a excel sheet?

偶尔善良 提交于 2019-12-12 04:03:22
问题 Using EPPlus I'm writing data to multiple sheets. If a sheet is not created I'm adding a sheet else I'm retrieving the used rows and adding data from that row and saving it FileInfo newFile = new FileInfo("Excel.xlsx"); using (ExcelPackage xlPackage = new ExcelPackage(newFile)) { var ws = xlPackage.Workbook.Worksheets.FirstOrDefault(x => x.Name == language.Culture); if (ws == null) { worksheet = xlPackage.Workbook.Worksheets.Add(language.Culture); //writing data } else { worksheet = xlPackage

Running a 32-bit window service which loads a 32-bit dll as a 64-bit service

╄→гoц情女王★ 提交于 2019-12-12 02:08:45
问题 Here's the situation - A window service which I am coding uses Linq2Excel, which insist the invoking application to be complied against x86. However, the window service is to be installed on a 64-bit Windows server. Using corflags, I am able to get the 32-bit window service to install. However, it'll refuse to load Linq2Excel. Here's the exception in all its glory: Exception occurs: Could not load file or assembly 'LinqToExcel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of

Create a list of objects that directly represents an Excel sheet

余生颓废 提交于 2019-12-11 09:07:58
问题 Using LinqToExcel, I'm trying to create a dynamic list of objects that have a dynamic number of properties (with values). Essentially, the list of objects should directly represent the contents of an Excel sheet. However, I don't know the header names or the number columns before hand. The code below does not work, it doesn't even compile, but I'm hoping it will show what I'm trying to do. Also it is missing a way to loop and add the correct number of properties. The names and number of

Can I specify the data type for a column rather than letting linq-to-excel decide?

梦想的初衷 提交于 2019-12-11 05:29:13
问题 I have noticed the following when working with linq-to-excel: I'm trying to import rooms from a spreadsheet. I have a simple class public class Room { public int BuildingID { get; set; } public string RoomNumber { get; set; } public double SQM { get; set; } public string Notes { get; set; } } The room numbers in the spreadsheet are either simple numbers e.g. 101, 102, 34 etc or they have a character prefix e.g. AV1, LH2 etc If the 1st row in my sheet starts with an alphanumeric room number (e