
If reading data from a column with mixed types then type is inferred as above and cells with alternate types will be returned as NULL You can use the VBA VAL() function to convert the text to a number. If there is no data in the rows then no type can be inferred so when writing the data, the provider will always write as text as this is the safer option.Type is not affected by Excel cell formatting settings.4 dates and 4 integers then the type follows type precedence which in Excel is numeric first (so integer wins in this case) If the top 8 rows have different types but the same number of each e.g.If the top 8 rows have different types then the majority rule.If there are more than 8 rows it uses the top 8 rows (not including the header).If there are less than 8 rows then it uses the data available.What are the rules for inferring type from the column? You can change the column type in the advanced properties of the Excel destination control in SSIS but this will just result in an error in the connection until you re-bind the sheet and the value will be put back to what the Excel provider thinks it should be.You can change the type of the data you are exporting at the source but it will still be exported in the format dictated by the already existing Excel sheet.It would be nice if they had looked at the data type of the data you want to put in to the sheet but they didn’t so tough!īecause the type is inferred from the Sheet you cannot specify the data type anywhere in SSIS as this would be pointless. Sadly when you write data to Excel, MS saw fit to use the same system which doesn’t really make sense. The column header (name) is assumed to be in the first row so the (column) type will be inferred from rows 2 to 9 (unless you specify otherwise in the connection string). When you read data from Excel using a provider such as Jet or ODBC then the type is inferred from the first 8 rows of data in each column. Columns therefore do not have a defined schema (As each cell in the column can be of a different type). You cannot define the data type in Excel.There are two major limitations affecting us right now. The connection provider (JET or ODBC) exposes the spread sheet workbook to look like it is a database with each sheet looking like a table, therefore we have rows of data organised in to columns which contain meaningful names (denoted by the text in the first row of the sheet) but this does not mean that the it supports all the properties of a database. By contrast all rows in a column within a database have the same type. This means each cell can have a different type within the same row or columm. That is, it is an entity in its own right and not part of a row or column other than by inclusion. The first thing to understand is that Excel is not a database! Why is this and how do we get around it so that the numeric data is exported as numberic in Excel? We want to export numeric data directly to Excel but the rows come out as “Number Stored as Text”
