In Rally we have a custom App which displays a table. Is there a way to export this table to Excel?
Rally Add-in for Excel looks good, but it only works for Office 2010 and we are stuck on 2007. But I did find this solution that's simple and it works in Firefox. Added a button to the app, when clicked I pass in the div_id of the table along with a Title.
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
window.location.href = uri + base64(format(template, ctx))
}
})();
var onClicked = function(sender, eventArgs) {
var buttonValue = eventArgs.value;
tableToExcel('mashup_table', 'Reviews Report Table');
};
Currently there is no way to export data from a table in an App.
Have you seen the Rally Add-in for Excel?
Michael,
You can try and use the data URI scheme to make your export work. It is possible to get the data from a AppSdk table and creating a comma delimited string. You could then make one of the special URIs to download the contents as a .csv and open them in excel.
We have been kicking around the idea of making the SDK be able to export it's data to from their components but the lack of constant support for data URIs has been a blocking point.
I don't know what browsers you have to support internally but that may be a nice start for a client side solution.
Here is a solution that works with ExtJs that you may find useful.
Related
I'm making mobile app with React-Native and i wanna get data from my API.But my API's datas , databases has html tags (you can see them in images which i shared) and some character codes because there are also Turkish characters.I already was using this API from my web site and there was no problem but when i try to get data to my react native app , it is getting data as a plain text as you see in my images.How can i get this datas without problem
It's called HTML entity. This is the code that works on browser (not on your case)
var decodeEntities = (function() {
// this prevents any overhead from creating the object each time
var element = document.createElement('div');
function decodeHTMLEntities (str) {
if(str && typeof str === 'string') {
// strip script/html tags
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, '');
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, '');
element.innerHTML = str;
str = element.textContent;
element.textContent = '';
}
return str;
}
return decodeHTMLEntities;
})();
The code are copied from here HTML Entity Decode
But it only works on the browser because the browser are automatically translate the characters for you.
I don't think passing around unserialized data like this is a good idea. You might want to encode data in server side using url encode or something then decode it in the react-native side
Reference
https://www.w3schools.com/charsets/ref_utf_punctuation.asp
Actually i solved it with this : https://github.com/archriss/react-native-render-html
Thanks
I'm working on a project that includes a module that helps with electricity recharge, so what happens is that the user's data is already saved in the app and when they choose to recharge, the app opens up this webpage in a web view.
Currently, I'm using WebBridgeView for opening the webpage as:-
render() {
return (
<WebViewBridge
ref="webviewbridge"
onBridgeMessage={this.onBridgeMessage.bind(this)}
source={{uri: "https://currencypin.com/PrepaidMeterPaymentsV2.0/cartwiz?c=IN&p=5&pm=tm"}}/>
);
}
}
Now, what I want is that when the webpage opens, the form fields come prefilled with the custom data that I have. So that the only field that the user needs to fill on the page is the CAPTCHA.
I was following this article for achieving the same, but it actually assumes that the website is customizable. Which is not possible in my case because it belongs to a 3rd party vendor.
What are the ways to achieve this?
You have to use the injectedJavaScript prop from WebView.
First declare a jsCode variable:
const amount = 2
const jscode = `
if (document.getElementById('txtAmount') == null) {
// field not existing, deal with the error
} else {
document.getElementById('txtAmount').value = '${amount}';
}
`
Please notice the " ` " character. Used to put variables in strings.
Then use it like so:
<WebViewBridge
ref="webviewbridge"
onBridgeMessage={this.onBridgeMessage.bind(this)}
injectedJavaScript={jsCode}
am working on a project to develop a thesaurus app using flash as3. However my app works fine but it only displays the synonym for the word already being put inside the thesaurus API url. However, I want my app to allow any user input through the input text field. Is there a way to do that? Many thanks in advance. I use "Big Huge Thesaurus API" for synonyms. For example in below API URL only synonyms for word "mother" are displayed.
"http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/"
Here is my full code.
button1.addEventListener(MouseEvent.CLICK, loadScores);
function loadScores(e:MouseEvent):void {
var fileLoader:URLLoader = new URLLoader();
fileLoader.addEventListener(Event.COMPLETE, scoresLoadComplete);
fileLoader.load(new URLRequest("http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/"));
}
function scoresLoadComplete(evt:Event):void {
try {
var returnVars = evt.target.data;
highscores.htmlText = returnVars;
trace("Data retrieved successfully");
for (var myVars in returnVars) {
trace(myVars + ": " + returnVars[myVars]);
}
trace("***********************");
} catch (err:Error) {
trace("Can't parse loaded file: " + err.message);
}
}
Have an input text box in your application and set its instance name to "userinput" and change the following line in your code.
fileLoader.load(new URLRequest("http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/"));
to
fileLoader.load(new URLRequest("http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/"+userinput.text+"/"));
I've created a scripted dashboard for Grafana v2.1.2 and would like to add it to the Home dashboard list, however don't see a way to do it using the GUI's dashboard settings.
Is it possible? And if so, is there some documentation or example on how to do this?
This seems to be an longstanding issue with grafana and is not supported as mentioned on https://github.com/grafana/grafana/issues/4145
But luckily there is a workaround as described on https://github.com/anryko/grafana-influx-dashboard/issues/54
You will have to create a new grafana dashboard. In dashboard settings you should rename it to "Scripted Dashboard". Then add a "text" row of "html" type. Then to the text field of that row you need paste this code:
<meta http-equiv="refresh" content="1;url=/dashboard/script/getdash.js">
<script type="text/javascript">window.location.href = "/dashboard/script/getdash.js"</script>
After this is done you will have to save the dashboard. That's it. Now from your Grafana Home screen you can select newly created "Scripted Dashboard" and it will automatically redirect you to the actual GetDash dashboard.
In Grafana 4, you add a text panel in a row and switch mode from Markup to HTML, then insert snippet above.
Downside of this solution is that such dashboards can't be used in playlists (will redirect out of playlist's url).
Be careful about URL (especially if you run grafana under /grafana path) as this redirect dashboard can not be deleted from web UI, you will need to use API for that or (as stated in above issue)
Create a new one with the same name. Then on saving action it will let you overwrite the old one.
Update: Grafana 6 does not allow workaround anymore :(
Yes, it is possible. But there is no direct way to implement this feature. Grafana allows dashboard API to create or update dashboards. You need to modify the default script dashboard object to adapt to this dashboard API as well as scripted dashboards.
Following is the default scripted dashboard:
'use strict';
var window, document, ARGS, $, jQuery, moment, kbn;
var dashboard = {
rows : [],
};
dashboard.title = 'Scripted Dashboard';
dashboard.time = {
from: "now-6h",
to: "now"
};
dashboard.rows.push({
title: 'Chart',
height: '300px',
panels: [
{
title: 'Events',
type: 'graph'
}]
});
return dashboard;
Modified script to achieve the purpose:
'use strict' ;
var window, document, ARGS, $, jQuery, moment, kbn;
var ScriptedDashboard= {
dashboard :{},
overwrite: true
};
/* Create a simple dashboard*/
function createDashboard(dashboard){
dashboard.title = 'Grafana Dashboard';
dashboard.time = {
from : "now-6h",
to : "now"
};
dashboard.id= null;
dashboard.uid= null;
}
function sendHTTPData(method, url, data){
var httpRequest = new XMLHttpRequest();
httpRequest.open( method,url , true);
httpRequest.setRequestHeader("Content-Type", "application/json");
httpRequest.setRequestHeader("Access-Control-Allow-Origin","*");
var reqData = JSON.stringify(data);
httpRequest.send(reqData);
}
createDashboard(ScriptedDashboard.dashboard);
sendHTTPData("POST", "http://192.168.0.104:3000/api/dashboards/db", ScriptedDashboard);
return ScriptedDashboard.dashboard;
See the difference between the above-scripted dashboards.
I can't find any packages to do this. I know PHP has a ton of libraries for PDFs (like http://www.fpdf.org/) but anything for Node?
textract is a great lib that supports PDFs, Doc, Docx, etc.
Looks like there's a few for pdf, but I didn't find any for Word.
CPU bound processing like that isn't really Node's strong point anyway (i.e. you get no additional benefits using node to do it over any other language). A pragmatic approach would be to find a good tool and utilise it from Node.
I have heard good things around the office about docsplit http://documentcloud.github.com/docsplit/
While it's not Node, you could easily invoke it from Node with http://nodejs.org/docs/latest/api/all.html#child_process.exec
You can easily convert one into another, or use for example a .doc template to generate a .pdf file, but you will probably want to use an existing web service for this task.
This can be done using the services of Livedocx for example
To use this service from node, see node-livedocx (Disclaimer: I am the author of this node module)
I would suggest looking into unoconv for your initial conversion, this uses LibreOffice or OpenOffice for the actual conversion. Which adds some overhead.
I'd setup a few workers with all the necessities setup, and use a request/response queue for handling the conversion... (may want to look into kue or zmq)
In general this is a CPU bound and heavy task that should be offloaded... Pandoc and others specifically mention .docx, not .doc so they may or may not be options as well.
Note: I know this question is old, just wanted to provide a current answer for others coming across this.
you can use pdf-text for pdf files. it will extract text from a pdf into an array of text 'chunks'. Useful for doing fuzzy parsing on structured pdf text.
var pdfText = require('pdf-text')
var pathToPdf = __dirname + "/info.pdf"
pdfText(pathToPdf, function(err, chunks) {
//chunks is an array of strings
//loosely corresponding to text objects within the pdf
//for a more concrete example, view the test file in this repo
})
var fs = require('fs')
var buffer = fs.readFileSync(pathToPdf)
pdfText(buffer, function(err, chunks) {
console.log(chunks)
})
for docx files you can use mammoth, it will extract text from .docx files.
var mammoth = require("mammoth");
mammoth.extractRawText({path: "./doc.docx"})
.then(function(result){
var text = result.value; // The raw text
console.log(text);
var messages = result.messages;
})
.done();
I hope this will help.
For parsing pdf files you can use pdf2json node module
It allows you to convert pdf file to json as well as to raw text data.
Another good option if you only need to convert from Word documents is Mammoth.js.
Mammoth is designed to convert .docx documents, such as those created
by Microsoft Word, and convert them to HTML. Mammoth aims to produce
simple and clean HTML by using semantic information in the document,
and ignoring other details. For instance, Mammoth converts any
paragraph with the style Heading 1 to h1 elements, rather than
attempting to exactly copy the styling (font, text size, colour, etc.)
of the heading.
There's a large mismatch between the structure used by .docx and the
structure of HTML, meaning that the conversion is unlikely to be
perfect for more complicated documents. Mammoth works best if you only
use styles to semantically mark up your document.
Here is an example showing how to download and extract text from a PDF using PDF.js:
import _ from 'lodash';
import superagent from 'superagent';
import pdf from 'pdfjs-dist';
const url = 'http://unec.edu.az/application/uploads/2014/12/pdf-sample.pdf';
const main = async () => {
const response = await superagent.get(url).buffer();
const data = response.body;
const doc = await pdf.getDocument({ data });
for (const i of _.range(doc.numPages)) {
const page = await doc.getPage(i + 1);
const content = await page.getTextContent();
for (const { str } of content.items) {
console.log(str);
}
}
};
main().catch(error => console.error(error));
You can use Aspose.Words Cloud SDK for Node.js to extract text from DOC/DOCX,Open Office, and PDF. It's paid API but the free plan provides 150 free monthly API calls.
P.S: I'm developer evangelist at Aspose.
const { WordsApi, ConvertDocumentRequest } = require("asposewordscloud");
const fs = require('fs');
// Get Customer ID and Customer Key from https://dashboard.aspose.cloud/
wordsApi = new WordsApi("xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx");
const request = new ConvertDocumentRequest({
format: "txt",
document: fs.createReadStream("C:/Temp/02_pages.pdf"),
});
const outputFile = "C:/Temp/ConvertPDFtotxt.txt";
wordsApi.convertDocument(request).then((result) => {
console.log(result.response.statusCode);
console.log(result.body.byteLength);
fs.writeFileSync(outputFile, result.body);
}).catch(function(err) {
// Deal with an error
console.log(err);
});