We have a legacy ASP page that writes content to an excel file by generating client-side VB script based on data from the database. It uses set app = CreateObject("Excel.Application") to initialize Excel.
The problem is that this is an "unsigned activex control", and some clients are now saying they wont change their IE settings to make it work.
Apart from re-writing the page in ASP.NET using Aspose.Cells (which would take a long time for this page), I was wondering if anyone knows any other options that could help?
Thanks!
Although this thread refers to ASP.Net, a lot of it may be of interest to you:
Send query results to Excel from ASP.NET website
It mentions creating HTML output and modifying the headers to output to Excel. This may also be of interest http://support.microsoft.com/kb/199841
Here is a very simple example.
<%
Response.ContentType = "application/vnd.ms-excel"
%>
<TABLE>
<TR><TD>
<!-- Cell : A1 -->
2
</TD></TR>
<TR><TD>
<!-- Cell : A2 -->
3
</TD></TR>
<TR><TD>
<!-- Cell : A3 -->
=SUM(A1:A2)
</TD></TR>
</TABLE>
Thanks for the response. The problem is that the our spreadsheet generated has lots of additional functionality, e.g. setting up some "validation" for certain columns - the HTML solution would not be able to do this I think.
However - your answer forced me to take another look at the code, and it turns out simpler than I thought to do this using an "Excel Writer" like Aspose.Cells :)
Related
I am building a map on Google Earth Pro to visualize political workers' data in a specific area. I have designed the basic elements in kml but the data used is hard coded in the kml file itself. I want to automate the process so that anyone can change the data in the master excel sheet and it gets reflected on Google Earth because the booth workers keep changing in every area for every election.
How can I fetch data from an excel sheet and represent it in a tabular format on Google Earth?
Sharing a snippet from the kml file:
`<Placemark>
<name>1,Dehradun</name>
<description><[CDATA[<div><b>PARTY WORKERS</b><br></div>
<table border="1">
<tbody>
<tr><br></tr><tr><td><b>SNO</b><br></td><td><b>NAME</b><br></td><td><b>CONTACT</b><br></td><td><b>COMMENTS</b><br></td><td><b>WORK ASSIGNED</b><br></td></tr>
<tr><td>1<br></td><td>Member1<br></td><td>9917973599<br></td><td>GOOD WORKER<br></td><td>BOOTH MGMT<br></td></tr>
<tr><td>2<br></td><td>Member2<br></td><td>8958644329<br></td><td>LAZY<br></td><td>MAKE PHONE CALLS<br></td></tr>
<tr><td>3<br></td><td>Member3<br></td><td>7894512547<br></td><td>SMART<br></td><td>DATA MGMT<br></td></tr>
</tbody>
</table>
<div><br></div><div><br></div><div><b>INFLUENCERS</b><br></div>
<table border="1">
<tbody>
<tr><br></tr><tr><td><b>SNO</b><br></td><td><b>NAME</b><br></td><td><b>CONTACT</b><br></td><td><b>COMMENTS</b><br></td><td><b>WORK ASSIGNED</b><br></td></tr>
<tr><td>1<br></td><td>Influencer1<br></td><td>9917973599<br></td><td>HIGH INFLUENCE<br></td><td>BOOTH MGMT<br></td></tr>
<tr><td>2<br></td><td>Influencer2<br></td><td>8958644329<br></td><td>ENTIRE BOOTH<br></td><td>NO WORK ASSIGNED<br></td></tr>
<tr><td>3<br></td><td>Influencer3<br></td><td>7894512547<br></td><td>SMART MAN<br></td><td>DATA MGMT<br></td></tr>
</tbody>
</table></description>
<styleUrl>#__managed_style_053287BE6F14D9C2C7B8</styleUrl>
<Point>
<coordinates>78.032188,30.316496,0</coordinates>
</Point>
</Placemark>`
Tried Spreadsheet Mapper V3.2 earlier but it doesn't seem to work now. Found out online that it has been discontinued.
I want this kind of output but it should come from an excel sheet instead of being hard coded:
enter image description here
In order to update a KML file from a spreadsheet, you'll need a server of some kind that can re-generate the KML when the spreadsheet is updated (like Spreadsheet Mapper used to do using Apps Scripts). This is not something that is "built in" to Google Earth, so there's not a simple solution.
That said, Google My Maps recently launched a feature where you can update a layer in your MyMap based on changing data in a spreadsheet. For info see this medium post:
https://medium.com/google-earth/new-my-maps-features-make-it-easier-to-share-maps-update-datasets-and-more-965ed0b48875
and this documentation page:
https://support.google.com/mymaps/answer/3024836
I'm not if it will be easy or even possible to update the data behind your custom balloon layout, but it's probably worth a shot. If you get it to work, then you can either have your users view the data directly in My Maps, or you can try getting the NetworkLink KML for the MyMap, and viewing that in Earth.
I have a document library in SP2013 that is full of forms. My users get confused by the "Check Out Required" box that pops up when they open the file. I keep telling them they need to download a copy, but this seems to be an issue. So, I looked into adding a "Download a Copy" button or link to the library, and came up with this solution, which is put in a snippet on a Web Part Page (source: https://amalhashim.wordpress.com/2013/11/29/sharepoint-2013-document-library-download-a-copy-button/):
<script type="text/javascript">
function runAfterEverythingElse(){
var elementArray = document.getElementsByClassName("ms-vb-lastCell");
var idArray = document.getElementsByClassName("ms-listlink");
for(var i = 0; i < elementArray.length; i++)
{
elementArray[i].innerHTML = '<a unselectable="on" href="javascript:;" onclick="window.open(\''+ idArray[i]['href'] + '\')" class="ms-cui-ctl-large " aria-describedby="Ribbon.Documents.Copies.Download_ToolTip" mscui:controltype="Button" role="button" id="Ribbon.Documents.Copies.Download-Large"><span unselectable="on" class="ms-cui-ctl-largeIconContainer"><span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float"><img unselectable="on" alt="" src="/_layouts/15/1033/images/formatmap32x32.png?rev=31" style="top: -409px; left: -35px;"></span></span><span unselectable="on" class="ms-cui-ctl-largelabel">Download a<br>Copy</span></a>';
}
}
_spBodyOnLoadFunctionNames.push("runAfterEverythingElse");
This partially works, in that it puts a button next to each document that says "Download a copy," but the action is actually just open the file in Word (instead of in the browser). The check-out prompt is still there, so I know it's opening the file and not downloading a copy. So while I like the way it looks, but the functionality isn't right.
In the answers to another question here (How to trigger a file download when clicking an html button or javascript), I found some instructions, but I can't figure out how to use them. I tried creating a workflow that created a download link and put it in an html-formatted field, but can't get the formatting right.
I don't really care if the solution is library-based (a field on each document probably created through Nintex Workflow) or Web Part Page based (script/snippet). I'm not fluent with jquery, javascript, or other programming languages. I know HTML, and can fumble my way through with CSS, but I'm pretty much a straight copy-paste from the internet solution kind of girl. I am not a programmer, just the person who manages our SharePoint site alongside may other job functions. :)
Any advice on how to tweak the original code or how to do this better is greatly appreciated. We're using SP2013.
#Kelly I implemented this solution in sharepoint 2010 using Dataview webpart.
Dataview webparts loops through all the documents in doc library and below code allow user to download the file.
Test.docx - Download a copy
I hope it helps. :)
I'm a coldfusion developer working on a reporting application to display information from a CFSTOREDPROC process. I've been able to get the data from my query to display correctly in a CFGRID, and I'm really happy with the display of the data. The grid saves a lot of time because it avoids using the CFOUTPUT tag and formatting the data in HTML for hundreds of reports.
All I would like to do is add a simple Disk Icon somewhere on the datagrid control that would save the contents of the datagrid and export it into an XLSX(2010) file that an end user could then manipulate in a spreadsheet program. This is important because the data needs to have a 'snapshot' at certain times of year saved.
Solutions Tried:
I looked into having a link from the report options page that would fire into a report_xls.cfm page but designing a page that catches all of the report options a second time seems dumb and would add thousands of CFM's to the website.
CFSPREADSHEET seems not to work for a variety of reasons. One is that the server seems to constantly fight me with the 'write' function in this tag. Another is that I don't know how to make the javascript work for this button to get the output that I want.
I also looked into doing this as a Javascript button that would fire based on the data entered. Although the data from a CFSTOREDPROC will display correctly if I use a CFOUTPUT block, CFGRID seems to have a hard time with all output styles except HTML. This has caused some difficulty with these solutions because the application doesn't spit out a neat HTML table but instead sends a javascript page section.
Raymond Camden's blog contains an entry Exporting from CFGRID that we used in our project.
The example in the article exports to PDF, but it is rather simple to modify the download.cfm file to export to Excel files as well:
You modify the file to generate the <table>...</table> HTML from his example in a <cfsavecontent variable="exportList"> tag, so that the #exportList# variable contains the table that will be shown in the spreadsheet.
Next we have a URL parameter mode that determines whether it is exported to PDF or Excel.
So the end of our download.cfm looks like the following:
<cfif url.mode EQ "PDF">
<cfheader name="Content-Disposition" value="inline; filename=report.pdf">
<cfdocument format="pdf" orientation="landscape">
<cfoutput>#exportList#</cfoutput>
</cfdocument>
<cfelse>
<cfcontent type="application/vnd.ms-excel">
<cfheader name="Content-Disposition" value="report.xls">
<cfoutput>#exportList#</cfoutput>
</cfif>
I'd like to go about offering a "download to excel" functionality for several different sets of data available on different parts of my coldfusion website. I'm using coldfusion and would love to use freely available custom tags / libraries that can help me accomplish this instead of coding it all myself from scratch. I've been pointed to cflib.org but am not sure how to get started. Anyone have any ideas, comments, or resources about downloading coldfusion website data to excel?
An approach that I have used in the past for an intranet with a load of tabular statistical data is to take advantage of the fact that Excel can read HTML.
On pages that I intend to provide Excel links for, I write out the core table as HTML to a file and include a link to that file in the rendered page. You can then serve this page with an .xls extension, use meta headers or even use an intermediary page with CFCONTENT in order to have your browser fire up Excel to display the content.
This approach can be extended for an arbitrary number of tables per page. You would have to write a tag to contain the table which will then take care of writing the file and supplying the download link for all HTML content contained within.
Sorry for the lack of example code. If my description of the process has left you scratching your head then I'll provide some examples for you.
You can also use an html table, as in:
<cfquery name="data" datasource="whatever">
...
</cfquery>
<cfheader name="Content-Disposition" value="inline; filename=fileName.xls">
<cfcontent type="application/x-msexcel" reset="true">
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td>Col1</td>
<td>Col2</td>
</tr>
</thead>
<tbody>
<cfoutput query="data">
<tr>
<td>#data.Col1#</td>
<td>#data.Col2#</td>
</tr>
</cfoutput>
</tbody>
</table>
hth,
larry
If you are on ColdFusion 9, you can always use cfspreadsheet:
http://www.cfquickdocs.com/cf9/#cfspreadsheet
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS434C35B0-279B-4051-A61B-D84B5D76189C.html
Building on #Ciaran Archer's answer, I usually use CSV to accomplish this, which Excel will open up from the web if installed on a client's PC. Assuming the data you're working with is coming out of a database, use the QueryToCSV() from Ben Nadel's site as such:
<cfquery name="data" datasource="">
...
</cfquery>
<cfinclude template="fun_queryToCSV.cfm">
<cfheader name="Content-Disposition" value="filename=my-file-name.xls">
<cfcontent type="test/csv" reset="true">
<cfoutput>#querytoCSV(data)#</cfoutput>
The "reset" on cfcontent clears the response buffer so that the only thing inside of it is what comes after. Alternately, if you already have the data as file, cfcontent has a "file" attribute that will serve its contents up directly.
In the end, we used the Query2Excel function from cflib.org, and modified it slightly to suit our specific needs.
For those on Coldfusion 9+ and able to use cfspreadsheet, you can leverage SpreadsheetReadBinary() to make the spreadsheet downloadable without having to write the spreadsheet to a file first.
It seems that when you copy something from a web browser to the clipboard, at least 2 things are stored:
Plain text
HTML source code
Then it is up to the software that you are pasting into can determine which one it wants.
When pasting into MS Excel 2003, you have a paste special option to paste HTML, which will paste the formatted HTML (as it is displayed by the browser).
What I want to do is paste the actual source code as plain text. Can this be fetched from the clipboard in VBA?
Edit I'm trying to access all the source-code of the copied HTML, including the tags.
This time I've read the question properly and realised coonj wants to get the HTML from the clipboard including tags.
I believe this is reasonably difficult. You need to read the clipboard using Windows API calls. And then, parse the resulting CF_HTML string which has some wacky headers added on top of the HTML.
Microsoft Knowledge Base article with Windows API code to read the CF_HTML from the clipboard (function GetHTMLClipboard).
You will then probably want to ignore the wacky headers. Microsoft documents the format here. An example CF_HTML fragment is shown below. You could probably come up with some guesswork method of skipping the first few lines.
Version:0.9
StartHTML:71
EndHTML:170
StartFragment:140
EndFragment:160
StartSelection:140
EndSelection:160
<!DOCTYPE>
<HTML>
<HEAD>
<TITLE>The HTML Clipboard</TITLE>
<BASE HREF="http://sample/specs">
</HEAD>
<BODY>
<!--StartFragment --> <P>The Fragment</P>
<!--EndFragment -->
</BODY>
</HTML>
It might also be worth thinking whether there's any other way of solving your problem. E,g, Will the browser always be Internet Explorer? Can you get what you need by walking the HTML tree using the COM object model?
EDIT: coonj has tried this now and says "the GetHTMLClipboard function seems to work with both Firefox and IE, and it doesn't look like it is throwing those headers in there"
VB6 has the Clipboard object that allows you to get the clipboard data in different formats. VBA doesn't have this object. But there are windows API calls you can use. You can see a sample implementation for VBA here.