certain fields get corrupted going from an Access report to an Excel spreadsheet - excel

I can't make sense of this. I'm using Access 2003.
The problem occurs when I right-click an Access report, then click "Send..." which has only one option of "Mail recipient". Then I click Excel. An Outlook window containing an outgoing email opens with an Excel attachment. There is one column with item ids. Some get corrupted while others do not. It seems they need to begin with the numerals 20 to get corrupted. Anything else comes out OK.
For example, the following item ids are ok:
100657
100657-17
216116-115
221007-001
The following get corrupted (the corrupted version follows):
202103-001 becomes 1313049
205103-001 becomes 2408777
Does anyone have any idea as to why this might be happening?

Check the formatting of source, it is possible that 20's are getting corrupted to date formates. This is particularly likely if the original source of the data being used by access is Excel. You likely want to set the format to text, particularly if you are using numbers to track ID's like stock numbers.
Also check what, format is used in Access for the Field. Excel is less likely to take liberties with your data when the Access field is set to text. If you continue to have problems after addressing the formats. Post more details about the formats in your question.

Related

MS Excel deleting the 0’s in the excel download of the report

MS Excel deleting the 0’s in the excel download of the report in OBIEE.
I have one primary id which has data like 001,002,003
The column is varchar and is treated as string in the report but when I export that to excel I'm getting 1,2,3.But I need the data should be like 001,002,003 only even after export.
I think excel is thinking this is number so it is cutting off zeros.
The user want to see data in excel exactly how it is displaying in report.
Any suggestion would be helpful.
You're sadly not specifying on which exact version this happens. The problem is definitely Excel and since this is a known issue, Oracle introduced a setting in OBIEE some years back. It lets you define whether to transfer raw data to Excel (as above where Excel then messes it up) or formatted, in which case your string stays a string.
In the instanceconfig.xml you can set the following:
UseFormattedValue
When you set that to UseFormattedValue, Execl is forced to accept the actual formatting. Not what Excel thinks the data is.
The other setting is UseRawValue.

Finding the cause of Excel file corruption

I have a feature that downloads things to an xls file using Apache POI. Mostly it works. But on one particular database, the resulting files are corrupted and won't open in Excel. I get the message "We found a problem with some content in 'DownloadFoo.xls'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes." . Clicking yes results in all the formatting, data validation, etc being stripped out. On the other hand, if I open the file in Open Office Calc and save it, it's fine and can be opened in Excel from then on. (The people who want to use these files aren't allowed to download Open Office Calc, so this is not considered an acceptable workaround.)
I have tried narrowing it down to see which data is causing the problem, but it seems to occur whenever 10 or more items are downloaded, regardless of which items they are. (On other databases, it's fine to download 100+). Excluding some of the columns helps, but they are perfectly innocuous looking columns (and virtually identical to other columns which are fine) so this still hasn't got me to the bottom of it.
Are there any techniques I could use to find out what Excel has a problem with in the corrupted spreadsheets?
I can't make major changes like getting it to download to xlsx instead as this feature is going to be scrapped and replaced with something completely different in the near future, so I'd like to just focus on the problem at hand.
It turns out that the solution to the problem was to reset the data validation lists more often. Quite a lot of the cells in my spreadsheet have data validation. When the data validation lists are longer, they are stored on a hidden sheet. If several cells need the same validation, I try to get them referencing the same list in order to not write out too much stuff on the hidden sheet. However Excel apparently dislikes it when too many cells reference the same list- it's not against the rules as far as I can tell, but it doesn't like it anyway. When I changed it to rewrite the validation lists for every 5 items, it started working.
The reason this database was different was that the items had an unusually high number of subitems, so they occupied a lot of rows even though it didn't seem like many things were being downloaded. Some of the problem columns just had true or false validation rather than using the lists on the hidden sheet, so I don't know what that was about, but resetting the validation lists helped anyway.
This doesn't really answer my question as I never managed to get any information from Excel about what the problem was, or use a particular technique, it was just a series of coincidental findings. I'm putting it here anyway in case anyone else has a similar problem. Also the thing that started me on the right track was finding an old comment when double checking that it doesn't do anything different for over 10 items (it doesn't) in response to Andrew Morton's comment, so thanks Andrew!

CrystalReports excel field cut off when using CanGrow=True

I am working on an excel report in CrystalReports, in VS2005. I have a field in the Details section which can have up to 255 characters of text, and I want the height of the row in excel to expand so that the entire text can be seen initially when the report is generated.
I set CanGrow=True in the field's properties, and the field does seem to grow; the field is only one line (Height=159), but many of the rows display multiple, wrapped lines of text. Some rows intermittently have the bottem half of the last line of text cut off; the user has to expand the row a little bit to see it. There doesn't seem to be a particular field length that causes this - in one case, it has four lines total in the output, and in another case, it has only three.
Can anyone suggest what might be the cause of this, or how I could work around it?
Thanks in advance for any help you guys can offer.
[Edit: I am no longer working on this project, so I never found out what became of this setting. Most likely it wasn't fixed, since it's not a critical issue.]
One solution to this issue that I've come up with in the past is to have two separate reports. One for display and exporting to pdfor rtf and another report for exporting to Excel.
I know in general this is not a good approach because there is the possibility for data to be different in the export than the display report, but if careful it works well.
I have a situation where a client needs data printed in a specific format on a report, but there is way to much data to physically be able to fit on a page. We worked out a solution that I run a "display version" of the report that fits most of the data, but the rest of the data necessary for there client is added only to the "Excel version" of the report.
To do this I simply load the "display report" to the report viewer as you normally would, but when you go to export the report I load the "excel report" with the same parameters as the "display report" and call the code to export the data to Excel.
By using this method the "display report" can be formatted any way necessary without having to worry about messing up the export to excel. The excel report fields can then be made a smaller size than required by the display report because the data should export even regardless of the size of the field. Doing this allows you to fit more data on the Excel export report.
Since both reports use the same datasource you will have an issue if you make a change that you have to remember to go verify the database on each report to see the new database changes, but this method allows you to include more data and in a different format than the display version of the report.
Hope this helps.
While not a solution for Crystal (I don't know of one), as part of the reporting team at GrapeCity-Data Dynamics, we've worked with similar issues taking free-form reports to excel spreadsheets for a decade. In our Data Dynamics Reports product we came up with a completely new way of solving the problem of exporting reports to excel.
We allow you to create a template for the report output. The template is a basic excel file with place holders for the various textboxes (or other controls) and regions (tables, lists, etc.) in the report. You can open this template inside of excel and modify the properties of the cells and rows. In the scenario you describe, you can export a "template" from Data Dynamics Reports and then modify the autosize property of the row in the template containing the placeholder for the textbox you're struggling with.
When you export the report to excel next time, just specify the template to Data Dynamics Reports (which can be done programmatically and transparently to the end user) and Data Dynamics Reports will honor all settings you specified in the template.
This is hard to explain so there is a ~2 minute screencast that shows this feature at our website in the following location:
http://www.datadynamics.com/Products/DDRPT/ScreencastViewer.aspx?ID=XLS01
For more information about the product and for a free trial download visit: http://www.datadynamics.com/DataDynamicsReports
Scott Willeke
GrapeCity - Data Dynamics

How to export SSIS to Microsoft Excel without additional software?

This question is long winded because I have been updating the question over a very long time trying to get SSIS to properly export Excel data. I managed to solve this issue, although not correctly. Aside from someone providing a correct answer, the solution listed in this question is not terrible.
The only answer I found was to create a single row named range wide enough for my columns. In the named range put sample data and hide it. SSIS appends the data and reads metadata from the single row (that is close enough for it to drop stuff in it). The data takes the format of the hidden single row. This allows headers, etc.
WOW what a pain in the butt. It will take over 450 days of exports to recover the time lost. However, I still love SSIS and will continue to use it because it is still way better than Filemaker LOL. My next attempt will be doing the same thing in the report server.
Original question notes:
If you are in Sql Server Integrations Services designer and want to export data to an Excel file starting on something other than the first line, lets say the forth line, how do you specify this?
I tried going in to the Excel Destination of the Data Flow, changed the AccessMode to OpenRowSet from Variable, then set the variable to "YPlatters$A4:I20000" This fails saying it cannot find the sheet. The sheet is called YPlatters.
I thought you could specify (Sheet$)(Starting Cell):(Ending Cell)?
Update
Apparently in Excel you can select a set of cells and name them with the name box. This allows you to select the name instead of the sheet without the $ dollar sign. Oddly enough, whatever the range you specify, it appends the data to the next row after the range. Oddly, as you add data, it increases the named selection's row count.
Another odd thing is the data takes the format of the last line of the range specified. My header rows are bold. If I specify a range that ends with the header row, the data appends to the row below, and makes all the entries bold. if you specify one row lower, it puts a blank line between the header row and the data, but the data is not bold.
Another update
No matter what I try, SSIS samples the "first row" of the file and sets the metadata according to what it finds. However, if you have sample data that has a value of zero but is formatted as the first row, it treats that column as text and inserts numeric values with a single quote in front ('123.34). I also tried headers that do not reflect the data types of the columns. I tried changing the metadata of the Excel destination, but it always changes it back when I run the project, then fails saying it will truncate data. If I tell it to ignore errors, it imports everything except that column.
Several days of several hours a piece later...
Another update
I tried every combination. A mostly working example is to create the named range starting with the column headers. Format your column headers as you want the data to look as the data takes on this format. In my example, these exist from A4 to E4, which is my defined range. SSIS appends to the row after the defined range, so defining A4 to E68 appends the rows starting at A69. You define the Connection as having the first row contains the field names. It takes on the metadata of the header row, oddly, not the second row, and it guesses at the data type, not the formatted data type of the column, i.e., headers are text, so all my metadata is text. If your headers are bold, so is all of your data.
I even tried making a sample data row without success... I don't think anyone actually uses Excel with the default MS SSIS export.
If you could define the "insert range" (A5 to E5) with no header row and format those columns (currency, not bold, etc.) without it skipping a row in Excel, this would be very helpful. From what I gather, noone uses SSIS to export Excel without a third party connection manager.
Any ideas on how to set this up properly so that data is formatted correctly, i.e., the metadata read from Excel is proper to the real data, and formatting inherits from the first row of data, not the headers in Excel?
One last update (July 17, 2009)
I got this to work very well. One thing I added to Excel was the IMEX=1 in the Excel connection string: "Excel 8.0;HDR=Yes;IMEX=1". This forces Excel (I think) to look at all rows to see what kind of data is in it. Generally, this does not drop information, say for instance if you have a zip code then about 9 rows down you have a zip+4, Excel without this blanks that field entirely without error. With IMEX=1, it recognizes that Zip is actually a character field instead of numeric.
And of course, one more update (August 27, 2009)
The IMEX=1 will succeed importing data with missing contents in the first 8 rows, but it will fail exporting data where no data exists. So, have it on your import connection string, but not your export Excel connection string.
I have to say, after so much fiddling, it works pretty well.
P.S. If you are using a x64 bit version, make sure you call the DTExec from C:\Program Files\Microsoft SQL Server\90\DTS.x86\Binn. It will load the 32 bit Excel driver and work fine.
Would it be easier to create the Excel Workbook in a script task, then just pick it up later in the flow?
The engine part of SSIS is good but the integration with Excel is awful
"Using SSIS in conjunction with Excel is like having hot tar funnelled up your iHole in a road cone"
Dr. Zim, I believe you were the one that originally brought up this question. I totally feel your pain. I love SSIS overall, but I absolutely hate the limited tools that come standard for Excel. All I want to do is Bold the Heading or Row1 record in Excel, and not bold the following records. I have not found a great way to do that; granted I am approaching this with no script tasks or custom extensions, but you would think something this simple would be a standard option. Looks like I may be forced to research and program up something fancy for a task that should be so fundamental. I've already spent a rediculous amount of time on this myself. Does anyone know if you can use Excel XML with Excel versions: 2000/XP/2003? Thanks.
This is an old thread but what about using a flat file connection and writing the data out as a formatted html document. Set the mime type in the page header to "application/excel". When you send the document as an attachment and the recipient opens the attachment, it will open a browser session but should pop Excel up over the top of it with the data formatted according to the style (CSS) specified in the page.
Can you have SSIS write the data to an Excel sheet starting at A1, then create another sheet, formatted as you like, that refers to the other sheet at A1, but displays it as A4? That is, on the "pretty" sheet, A4 would refer to A1 on the SSIS sheet.
This would allow SSIS to do what it's good for (manipulate table-based data), but allow the Excel to be formatted or manipulated however you'd like.
When excel is the destination in SSIS, or the target export type in SSRS, you do not have much control over formatting and specifying how you want the final file to be. I have written a custom excel rendering engine for SSRS once, as my client was so strict about the format of final Excel report generated. I used 'Excel xml' to get the job done inside my custom renderer. May be you can use XML output and convert it to Excel XML using XSLT.
I understand you would rather not use a script component so perhaps you could create your own custom task using the code that a script contains so that others can use this in the future. Check here for an example.
If this seems feasible the solution I used was CarlosAg Excel Xml Writer Library. With this you can create code which is similar to using the Interop library but produces excel in xml format. This avoids using the Interop object which can sometimes lead to excel processes hanging around.
Instead of using a roundabout way to do this exercise of trying to write data to particular cell(s), format the cell(s), style them which is indeed a very tedius effort considering the support SSIS has for EXCEL, we could go the "template" way to do this.
assume we need to write data in the so & so cell with all the custom formating thats done on it. Have all the formatting in a sheet, say "SheetActual", Whereas the cells that will hold the data will actually have Lookups/ refrences/ Formulaes to refer to the original data that SSIS exports in a hidden sheet say "SheetMasterHidden" of the same Excel connection. This "SheetMasterHidden" will essentially hold the master data in default format that SSIS writes data to the excel. This way you need not worry about formatting the data runtime.
Formatting the Excel is a one time work "IF" the formatting dont change very often. If the format changes and the format is decided runtime this solution maynot go very well.
The answer is in the question. Over time, it became a progress status. However, there is SSRS that will create Excel files if you create TABLE presentations. It works pretty well too.

Importing Excel into SS2000; Error on Field; DTS

I'm trying to import an excel file in to a SQL Server 2000 database using DTS. This is nothing fancy, just a straight import. Where I work, we do this 1000 times a day. This procedure usually works without an issue but something must have changed in the file.
I'm getting the below error:
Screen shot of Error http://www.understandingguitar.org/wp-content/uploads/2008/12/packageerror-screenshot-20081212.jpg
I've checked to ensure that the column "AssignmentID" is stored as "text" in the excel sheet. I've also tried to change it to general. Exact same error regardless of setting. The field does contain numbers... I appreciate everyone's help on this!
Regards, Frank
Try opening at the excel file and see the column content.
Is any of the row value in that column right-aligned? (generally for numbers)?
I am guessing that such a row could be a problem.
It may be obvious, but is the destination string long enough to hold the string representation of the float? I'm not sure if Excel is rounding what it displays to you, so it may be worth trying with a wider column.
The answer has something to do with the fact that the procedure is expecting text but even if you set the properties (in the format dialog) to "text", excel may not handle the data as text. And hence, SQL Server (or the libraries) won't handle it to text.
When the procedures try to import it, the system feels that it is converting from a number to text and it expect that data maybe lost (even though no data will be lost) and the error is raised.
If figured out that I can get around this error by placing a ' (apostrophe) before each listed number. [I.E. '124321] This force excel to treat the number as text.
Hopefully this will save others the headache I now have from this. :-)
Regards,Frank

Resources