Is it possible to link a cell In Excel to a local file with a querystring? - excel

I had wanted to put a solution onto a thumb drive or dvd to be distributed as needed. I have a couple html pages with javascript to display photos and some other info. I also have an excel spreadsheet (2003) that I wanted to link to the html page. However when I try to use a querystring I get a warning from excel stating that it "cannot open the specified file."
edit: I use javascript to parse the querystring and load a specific photo and some info.
This does not work:
=HYPERLINK("site_photos.htm?p=1", "photo 1")
This works:
=HYPERLINK("site_photos.htm", "photo 1")
Any help here would be greatly appreciated.
edit:
Okay, I've tried using ThisWorkbook.FollowHyperlink procedure using the extrainfo and not using the extrainfo parameter. This did not work. I also tried using a shell command. This also did not pass the querystring either. It looks like I will need another solution.
edit:
Here's the javascript function used to retrieve the querystring. The querystring is not in the window.location.href so this will not work when called.
function parseUrl(name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexStr = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexStr );
var results = regex.exec(window.location.href);
if( results == null )
return "";
else
return results[1];
}

Whether it is possible to perform the original task or not, I have opted for a different solution. I will use image controls to view the photos and other controls for navigation.

Related

Is it possible to catch the response of search feature available in url

I am trying to write automated screenshotter using puppeteer in node.js which will navigate to particular url.url have one faeture for search box which will give the information for desired query.If we get desired output screenshot is taken and saved to "success" folder but we didnt get any result (like no result found), i want screenshot in "failure" folder. Is It possible to record the response and segregate the screenshots.
You can check html value and return value with page.evaulate() then you can use switch case according to incoming value and use page.screenshot() function.
Here is your question broken down to bits,
You are trying to,
write automated screenshotter using puppeteer in node.js
which will navigate to particular url.
url have one feature for search box.
which will give the information for desired query.
If we get desired output
screenshot is taken and saved to "success" folder
but we didnt get any result (like no result found),
i want screenshot in "failure" folder.
Is It possible to record the response and segregate the screenshots?
The answer is, Yes.
For example, it can be a simple google/yahoo/duckduckgo results scraper . Save screenshot depending on the result count.
You can use .goto to go to the page, .$$ to check the results, .screenshot to take screenshot depending on the results.
Here is an example code to check if there is any result or not,
let results = !!await page.$("div > div > h3 > a");
// returns if there is any result in google search
let path;
if (results) {
path = "success/mysuccessimage.png";
} else {
path = "failed/myfailimage.png";
}
await page.screenshot({ path });
Since you did not share any code, no one will be able to help you. But I guess I answered your question. Now, you can implement it in a thousand ways, peace.

Web Api HttpResponseMessage not returning file download

I am currently doing a POST to a Web Api method and am posting an array of objects. When I get to the method, my parameters are resolved properly, and I make a call to the DB and return a list of records.
I then take those records and convert them to a MemoryStream to be downloaded by the browser as an Excel spreasheet. From there, I create an HttpResponseMessage object and set properties so that the browser will recognize this response as a spreadsheet.
public HttpResponseMessage ExportSpreadsheet([FromBody]CustomWrapperClass request){
var result = new HttpResponseMessage();
var recordsFromDB = _service.GetRecords(request);
MemoryStream export = recordsFromDB.ToExcel(); //custom ToExcel() extension method
result.Content = new StreamContent(export);
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
result.Content.Headers.ContentDisposition.Name = "formName";
result.Content.Headers.ContentDisposition.FileName = "test.xlsx";
return result;
}
Instead of seeing the spreadsheet being downloaded, nothing seems to happen. When I check the developer tools (for any browser), I see the Response Headers below while the Response tab just shows binary data. Does anyone know what I might be missing here?
How are you doing your POST? It sounds like you might be trying to this via a javascript AJAX call, which cannot be done (https://stackoverflow.com/a/9970672/405180).
I would instead make this a GET request for starters, and use something like window.location="download.action?para1=value1....". Generally web api Post requests are made to create a file/entry, not retrieve one.
Alternatively, you could use a HTML Form with hidden elements corresponding to your query parameters, and use javascript to submit the form.

How do you get the filename from the XPages FileUpload Control

In XPages, in the file upload control, after a user selects a file but before it's saved how can you get the filename? I'm not interested in the path as I believe that's not getable due to security issues but I would like to get the filename and extension if at all possible.
Thanks!
Actually you can get the file and fully manipulate it, read it, do whatever you want with it, its stored in the xsp folder on the server, to which you have read/write access... here is a code snippet that interacts with the file, I usually call from beforeRenderResponse...
var fileData:com.ibm.xsp.http.UploadedFile = facesContext.getExternalContext().getRequest().getParameterMap().get(getClientId('<INSERT ID OF UPLOAD CONTROL HERE (ie. fileUpload1)>'));
if (fileData != null) {
var tempFile:java.io.File = fileData.getServerFile();
// Get the path
var filePath:String = tempFile.getParentFile().getAbsolutePath();
// Get file Name
var fileName:String = tempFile.getParentFile().getName();
// Get the Name of the file as it appeared on the client machine - the name on the server will NOT be the same
var clientFileName:String = fileData.getClientFileName();
}
It sounds like you are referring to needing to get the data via CSJS, which you can do with the following code:
var filename = dojo.byId('#{id:fileUpload1}').value.split('\\').pop();
These links should be able to help you.
http://www.bleedyellow.com/blogs/andyc/entry/intercepting_a_file_upload4?lang=en
http://www.bleedyellow.com/blogs/m.leusink/entry/processing_files_uploaded_to_an_xpage?lang=en

How do I programatically fetch the live plaintext contents of an etherpad?

This question came up on the etherpad-open-source-discuss mailing list and I thought it would be useful to have it here.
Just construct a URL like so and fetch it:
http://dtherpad.com/ep/pad/export/foo/latest?format=txt
That will get the live, plaintext contents of http://dtherpad.com/foo
For example, in PHP you can grab it with
file_get_contents("http://dtherpad.com/ep/pad/export/foo/latest?format=txt")
Note that that's just the "export to plain text" link that's provided in the Import/Export menu of every pad.
A few other possibilities:
From a browser, you can hit http://your-etherpad-server.com/ep/pad/view/padId/latest?pt=1
From within the code of the collaborative editor (ace2_inner.js), use rep.alltext
Within the Etherpad's javascript, use pad.text for the most recent version of pad.getRevisionText(rev.revNum) for a specified previous revision.
It seems that the javascript functions mentioned by Ari in his response are no longer present in the current versions of Etherpad as implemented on sites like http://etherpad.mozilla.org
However you can now simply use the following javascript function, within eherpad's javascript to get the text of the latest revision
padeditor.ace.exportText()
You can get the plaintext content of etherpad using jQuery as:
jQuery(document).ready(function(){
jQuery('#export').click(function(){
var padId = 'examplePadIntense';//Id of the div in which etherpad lite is integrated
var epframeId = 'epframe'+ padId;
var frameUrl = $('#'+ epframeId).attr('src').split('?')[0];
var contentsUrl = frameUrl + "/export/txt";
jQuery.get(contentsUrl, function(data) {
var textContent = data;
});
});
});
You can also use the getText HTTP api to retrieve the contents of a pad.
See my other answer for more details.

Grails: How do I make my list a MS Excel file?

gsp is divided into two, the top part is like a search filter, and the bottom part is the regular list that is provided by Grails
I have a template _list.gsp in my list.gsp. And I wanna create a button to make that _list.gsp template a MS Excel file.
But I want only the template to be on the Excel file. Not the rest of the page
How can I do this in the simplest and direct way possible?? Thank you!
you can also take a look at the export plugin if you want to export the list to excel format
http://www.grails.org/plugin/export
Try this quite dirty trick in your index method:
response.setHeader( 'Content-Disposition', 'attachment;filename=list.xls' )
Explanation: the trick is that an HTML page renamed as *.xls can be read by office software suites. What you're doing is telling the browser to download a file with that name, instead of navigating to a regular HTML file. If you want to use this in a button, you should proceed as with any HTML generating page, and then add this header to the response. response is global to actions in Grails controllers.
All you need is to send search data to your controller, in the controller you can send content as explained by mschonaker, this is an example of what I did
def report = {
def reportType = params.report
....
.....
//Service class that collects data based on search data passed in params
def data = reportservice.execute(param)
//called export plugin to generate xls file
response.contentType = ConfigurationHolder.config.grails.mime.types[params.format]
response.setHeader("Content-disposition", "attachment; filename=${fileName}")
exportService.export(...)
}
Take a look at the Excel-export plugin. This has support for downloading only in .xlsx format. Exports an excel with the simplest coding.
I switched to this plugin from export plugin since had a clash with rendering plugin.
https://grails.org/plugin/excel-export
response.contentType = 'application/vnd.ms-excel'
response.setHeader("Content-disposition", "attachment; filename=OrderList.xlsx")
new WebXlsxExporter().with { //pass the contructor with "templateFileNameWithPath"
setResponseHeaders(response,new Date().format('dd-MM-yyyy_hh-mm')+"OrderList.xlsx")
fillHeader(labels)
add(data, fields)
save(response.outputStream)
}
response.outputStream.flush()
response.outputStream.close()}

Resources