Exporting data from one excel sheet into a new excel sheet using Microsoft Office apps 2013 - office-2013

Im facing a problem with Task Pane control of Microsoft Office Apps 2013, I've created an Office 2013 App wherein im writing data on the excel using the office app and reading back from it. This is working fine, but now I want the values read from the current excel sheet into another new excel sheet. Now I've written a code to do this from some references on the internet using javascript and it works on the browser. But im not able to get it to work on the app.
It'll probably work if I get the current instance of the excelsheet in working on, but I don't know how to get that either. im attaching the javascript code along with this post.
One more thing, when I open the app in excel it shows the following error message
An add-on for the website failed to run. Check the security settings in internet options. I tried changing the settings in internet options and set everything to enabled. still im getting this error.
Any help is much appreciated.
Thanks.
var MyArray = [['Berlin'],['Munich'],['Duisburg']];
function writeToExcel() {
var i, j, str;
var myTable = MyArray;
alert(myTable.length);
var rowCount = myTable.length;
var excel = new ActiveXObject('Excel.Application');// Activates Excel
excel.Visible = true;
excel.Workbooks.Add(); // Opens a new Workbook
excel.Application.Visible = true; // Shows Excel on the screen
var i=0
myTable.forEach(
function(item)
{
alert(item)
excel.ActiveSheet.Cells(i + 1).Value = item; // Writes to the sheet
i=i+1;
}
);
return;
}

As I know, the Javascript API don't support to create new sheet.
You can reference the following link:
http://social.msdn.microsoft.com/Forums/en-US/appsforoffice/thread/01c75559-a591-4d2b-a0ea-24103cdea1d5

Related

Reading Data from excel sheets in Katalon studio

How to read data from excel sheets(sheet 1,sheet 2...etc) in Katalon Studio.
I am able reading the data from one sheet.But I am facing the difficulty with multiple sheets.
Without knowing exactly what the problem you face is, here are my first suggestions to check:
You do have to create different Test Data files for each sheet in your file that you want to use. Two Test Data files for the same spreadsheet file
In your new Test Data inside Katalon, just select your file and then you can select the different sheet. Sheet selection options
If you can't see a sheet in the drop down on your Test Data page (perhaps you just added it to the spreadsheet) refresh your project, or at the very least refresh the Test Data. (ctrl-F5 to refresh the entire project, highlight the Test Object and then right-click and select or hit F5 to refresh the Test Data)
Hope this helps.
You cannot switch excel sheets from Katalon, at least natively. Maybe with some custom programming.

How to open new Word docx document in word Add-in

I have developed a word add-in using word javascript api. My Document .docx file is on server and i need to open that .docx document as a new word document on a button click in add-in.
Please guide me how i can open new document in word add-in.
Thanks.
There is a new method we are adding to the API that you can actually use to achieve this. Notice that is in preview, which means will be in production in a couple of months. You need latest Office version plus reference our preview office.js to try it. The office.js preview is here https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
Check out this code sample on how easy is to do it.
function onaddOpenDoc() {
Word.run(function (context) {
// this getDocumentAsBase64 assumes a valid base64-encoded docx file
var myNewDoc = context.application.createDocument(getDocumentAsBase64());
context.load(myNewDoc);
return context.sync()
.then(function () {
myNewDoc.open();
context.sync();
}).catch(function (myError) {
//otherwise we handle the exception here!
showNotification("Error", myError.message);
})
}).catch(function (myError) { showNotification("Error", myError.message); });
}
Opening a document in a new instance (i.e. a new, separate Word window) is, at least for the time being, not supported by the JavaScript-based Office.js API. You are always starting from a Context object, which will give you access to the currently active document via the Context.document property.
What you can do is insert content into an existing document, e.g. via the body.insertOoxml method.
Currently, the Office.js API is still limited as compared to the classic COM API. If you need the full feature-set you still might consider developing a COM or VSTO solution today. The only downside is that your add-in won't run on any platform other than Windows desktop.

Tableau Workbook No Longer Displaying Data

I saved a Tableau workbook on Nov 2015. Now when I open it, none of the maps or graphs appear in any of the tabs.
However if I hover over the tab, it shows thumb-file of the graphic, i.e.
Please tell me how to repair this. Else it will take lot of resources to re-create tableau workbook again. Thanks!
Worksheet is already auto-updated

Attach google spreadsheet as pdf to email

I would like to create a PDF of a specific sheet (not necessarily the active one) and send it as an email attachment. I've borrowed and tried several code snippets, but none work correctly. I've searched and analyzed all the forums I can find, but I can't figure out the issue. I'm a novice programmer, so I like it simple. This snippet is intuitive to me, but it gives the following error: "We're sorry, no servers are currently available. Please wait a bit and try again." Debugger says that both pdf and attach are undefined.
var pdf = SpreadsheetApp.getActive().getAs('application/pdf').getBytes();
var attach = {fileName:'test.pdf',content:pdf, mimeType:'application/pdf'};
MailApp.sendEmail(recipients, subject, body, {attachments:[attach]});
Three things:
can you help me get the pdf/attachment function working properly?
can you help me modify it for a specific sheet (say, Sheet1)?
is it possible to make a pdf out a range on a sheet rather than the whole sheet?
Thanks!
You're trying to apply methods of one Class to another that does not implement it. (e.g. getAs() isn't a Spreadsheet method.) When you're writing your script, pay attention to the autocomplete feature, which would have helped to avoid this error. See this previous answer for more details about that.
Answers:
See Google Apps Script to Email Active Spreadsheet, which demonstrates how to generate a PDF from a sheet.
To isolate a single sheet, see ajb1970's answer to the same question. The idea here is to copy the sheet you're interested in into a new, temporary, spreadsheet - and then make your PDF from that.
To do this with a range, repeat step 2, but with the range you're interested in.
Use getBlob not getBytes. Also you cant specify a specific sheet. Instead copy that sheet into a new spreadsheet, convert that one to pdf and later delete it.

PDF.js with GWT application does not work

We have an application built on GWT framework where we want to display a PDF file without any browser plugin and are currently evaluating PDF.js to do that.
The problem is, no matter what I do, I am not able to render a PDF file onto a canvas in our GWT application. Do give some background
The PDF file ticket is retrieved from server.
The PDF.js file ticket is retrieved from server and is embedded in the HTML body by using this script
var head= document.getElementsByTagName('body')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.setAttribute('charset', 'UTF-8');
script.src=url;
head.appendChild(script);
Canvas element is created in the View (using googles MVP pattern here) and a JSNI call is made to the script which embeds the PDF.js in the HTML body using the above function. The script then makes a call to function which works with PDFJS class defined in PDF.js file.
The function to render the PDF file on canvas is as below :
PDFJS.disableWorker = true;
PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf)
{
pdf.getPage(1).then(function getPageHelloWorld(page)
{
var scale = 1.25;
var viewport = page.getViewport(scale);
canvas.height = viewport.height;
canvas.width = viewport.width;
page.render({canvasContext: context, viewport: viewport});
page.startRendering(context);
alert("Finished rendering");
});
});
The canvas and context are created in the View class and passed to the javascript.
The problem here is, after the call to JSNI is made, I show alerts of all variables. The browser shows alerts except when I make a call alert(PDFJS). This shows that PDFJS variable is not being recognised in the script.
This makes me think PDF.js file is not correctly embedded in the view or there is something else that I am missing.
Note: I have downloaded most of the examples over the net and most of them work locally i.e. I can modify the PDF.js file path to pick up a local copy and the HTML still renders the PDF. It has no problem reading the PDFJS variable. Its only in this GWT application that I see these problems.
Does anyone have any clue whats happening. Your help will be highly appreciated.
Thanks
Your problem is that you're injecting the script so it aloads asynchronously, but you don't wait until after it's loaded to start using it.
Try using ScriptInjector.FromUrl to inject the script and put the rest of your code in the Callback's onSuccess.
Injecting the script synchronously (by adding it to your HTML host page, or GWT Module descriptor —note: won't work with the xsiframe linker—), as proposed by Ilya is of course also a solution.
Try to add <script src="PDF.js"/> in your .gwt.xml file and put PDF.js file in your public director