Export to Excel using ASP - excel

At the time of exporting to excel using ASP. After converting a column in text format single quote is visible in the excel file. how to hide this automatically ?

You might be helped by setting the style of your cell to mso-number-format:"\#", but I'd have to see your code to know the exact problem.
I think you might find Styling Excel cells with mso-number-format and Generate Excel files in ASP Classic useful.

When you export to excel, you could juste make a table with cell, and put your value into double quote. Excel will read it correctly

Here's the library I use, to export data to Excel 2007 (.xlsx) files.
It lets you export any DataSet, DataTable or List<> directly into an Excel 2007 file, using one line of code.
It's completely free, and you can download the source code (and see how to use it) here:
http://www.mikesknowledgebase.com/pages/CSharp/ExportToExcel.htm

Related

How to format a formula in Microsoft Excel to be in percentage format DIRECTLY in the CSV source file

The problem:
For example, my CSV data is like so: ['=B3/B5'] which displays 0.1 in my Excel sheet but I need it to produce 10%.
I need to be able to fix this from the CSV source data because I'm exporting a CSV file from my website so that means no excel formatting to percentages as I need it to work out of the box for users.
Preferably the solution should be able to support Excel 2007. Google Sheets has a =to_percent(B3/B5) function which works well but I need the equivalent for Excel 2007.
I had a look at this answer: https://superuser.com/questions/318420/formatting-a-comma-delimited-csv-to-force-excel-to-interpret-value-as-a-string
But doesn't seem to directly address the problem.
You could use =B3/B5*100&"%"
Note that this will not be saved as a number (ex. 22.1%) rather as text, because you can't use number formats in a CSV file.

How to export cells with links, when saving to a csv?

I am trying to export an Excel file (.xlsx) to a csv, with LibreOffice. Some columns have hyperlinks, which I can open when the sheet is open in LibreOffice. The cell does not show the link, but a short summary text: the link is somehow a property of the cell (or the text, not sure).
I would like that the CSV contains the links for the affected columns (I don't care about the short summary text), but by doing a "Save As csv" I am losing the links. What can I do?
EDIT
I have investigated a bit: the hyperlink can be manually created in Libreoffice in a cell with Ctrl-K or from the menu Insert -> Hyperlink. When I try to export the csv, I am offered two relevant options:
save cell content as shown
save cell formulas instead of calculated values
I have played around with them, but those are not helping at all.
Is there any way of exporting the hyperlinks instead of the text?
From what I can tell, the CSV export filter always saves the link text, not the link URL. This behavior occurs when saving from LibreOffice format as well, so your question does not need to involve Excel or the .xlsx format.
What I would probably do is write a macro to create a CSV file with the URLs. If you want to try that, then have a look at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Accessibility/XAccessibleHyperlink.
Depending on what you are trying to do and how much time you are willing to invest, you can create your own filter.
Another option that requires programming would be to use the HTML export filter, which saves both the link text and link URL, and then write some code to parse out the URL.

Using Excel Macros in both XLS and XLSX

How can i use the same macro in both the XLS and XLSX formats?
Is there anyhthing to be added in the XLSX format. i have written a small macro in XLSX (it has last column XFD) i want to use it in the XLS (it has last column as IV) .Is there anything to be changed?
This question is not about converting the file formats.
XLSX provides a broader set of formulas and also VBA functionality. Additionally, XLSX expands the row/column restriction that exists before Excel 2007 (from 256 columns to 16,384).
If your macros are written using up to column 16,384 (XFD), you're going to have to perform the calculations in chunks to make them fit within the 256 column (IV) restriction of Excel 2003. If you're using variables and not writing everything to a sheet, then there should be no problem (barring running out of memory).
Without more detail, it's difficult to tell whether you're using a set of functions from Excel 2007 that may not be supported in Excel 2003.
Which format was it written first? normally it should work in both formats of excel. As you are referring to last cell of both formats, it seems to have a code level issue than a version lavel.

Excel and Tab Delimited Files Question

I am encountering what I believe to be a strange issue with Excel (in this case, Excel 2007, but maybe also Excel 2003, but don't have access to it as I write this).
I can reliably convert some server data over into a tab-delimited format (been doing this for years) and then open it using Excel - no issue.
However, what seems to be happening is if I have an html <table> inside one of the fields, it looks like Excel 2007 thinks it should be converting the table into rows and columns inside Excel (not what I want). As you might imagine, this throws off the entire spreadsheet.
So question is, is there any way to set up excel to NOT do this (perhaps some setting in Excel that pertains to reading tab delimited files), or am I missing something?
Thanks.
Save your file as .txt
Now open the file in excel using Drag and Drop (rather than double clicking your hookey .xls)
Slightly more work to open the file, but your tab text formatting will now be respected.
When you open the tab-delimited file, you are shown an import mapping dialog that lets you pick each columns' data type (date, text, currency, etc.). For the columns that have HTML data present, choose text. This will tell it basically to import as-is and not try to automatically parse the data into a derived format.
Excel 2003 does the same. I don't think there is a way to do it with a config because Excel finds delimiters in the html table and breaks the html in cells and columns as it does for the other columns.
If the column containing html is always the same, you can use JYelton suggestion of renaming the file as csv and record a small VBA macro to load the file selecting automatically the html column as text in the import mapping dialog and you load the file calling the macro instead of double-clicking on the file.
If nothing else, import it into OpenOffice.org Calc, save as an .xls file, then open in Excel.

SSRS export to Excel UNFORMATTED

I'm looking into SSRS with intention of exporting a lot of the reports to excel. The problem is that when you export it changes cell sizes and removes borders to try and keep the original report format.
Is there anyway to stop this happening? So that the report exports to excel with the "usual" excel formatting? If it requires any coding that's fine as most of my reports will be run from C# code.
Thanks
Mat
You could export to a CSV and import that into a spreadsheet, possibly with some sort of template sheet for the particular report.
You could export the data to Sheet2. Mark sheet 2 as hidden.
Create your designer report on Sheet1.
Run an Excel Macro to read data from Sheet2 and put on Sheet1.
It's not pretty, but you could consider generating Excel sheets from the XML renderer, as described here - this would give you full control over the appearance of the worksheet.
I think what's happening is that you have stacks of fields in your reports that aren't aligned with each other and so when you export to excel, it compensates and generates extra columns to try to come close to what you report looks like.
I used to get this all time and then I figured out that if you used as little tables as possible while using more grouping within that grid, it goes along way to send a clean format to excel. Also watch out if you use a report header whose ends don't align to columns within the report.
So match object's begin and ends with other objects' or span of cells' begins and ends.
I create a seperate report with the same data, but no formatting.
Include a button to export on the main report, and when they click it, it directs them to an unformatted version of the report that is automatically exported to Excel.

Resources