Script to copy range/cells value from Google Spreadsheet - paste in Excel - javascript

I'm looking for a script that can simply help me COPY a specific range in Google Spreadsheet so I can just paste it in an Excel file where this data will be processed.
The "dream" solution would be to connect and paste automatically the range from the G-Spreadsheet into the Excel file, but if there is a possibility to run a script that will "memorize" all the wanted range so I can just click "paste" in Excel - it would be a life saver!
Many thanks!

Appscript has a method getRange where you can use to copy data from one Google spreadsheet to another, but Google spreadsheet to Excel operations is not yet supported
something to that effect. What do you think?
For the meantime, you might reconsidering downloading your spreadsheet as csv so that you can open your google spreadsheet contents in Excel.

I would process data in Google Sheets. It's better. But if you insist...
First, write GAS code on source Google Sheet. The script executes these steps:
fill all unwanted area xxx or something.
save the sheet to csv file.
now, undo step 1.
Second, write VBA code on target Excel file. The script executes these steps:
open the csv file created by above GAS code.
read all values. You may skip xxx.
pastes those values into specific target area.
Then you just click one time in Google Sheets, and click another time in Excel and tadah! You got it.
Again, I would process data in Google Sheets.

Related

Is there a way to upload a text file to Google sheets with delimiters or something to similar to regex to populate the cells

I'm no expert in google sheets right now. I was wondering if there was a way to upload a text file and populate the cells following a type of regular expression or set of rules to control which data is mined.
From my knowledge, using App script (javascript), I should be able to open the file using a method. Read the file while a function is run to validate the data demanded. The data is then put into specific cells accordingly.

Copy Spreadsheet Ready CSV to Clipboard

I would like to display some comma separate values to a user in JavaScript (but really, language is not the point here) and allow them to paste that right into their spreadsheet program, much like SQL Server Management Studio does.
For example, in SQL Management Studio (and other programs), if I select the columns here, I can paste those right into Excel, no formatting or importing needed.
If I just output CSV as it is:
It puts everything in one row:
What do I need to do to my output to make it so when I copy it, I can just easily paste it into a spreadsheet program?

How to read a iqy file result table with javascript

so I have an IQY file (Internet Query file), it's found locally on my computer. This file when opened in excel will show me a table of a SharePoint list. I would like to use JavaScript, in IE browser (I can use ActiveXObject if needed) to search the resulted table for a value.
I already know how to search in excel, So that's not the problem. How can I turn this IQY file into an temp excel sheet with JavaScript? If it's not possible, is there a way to read from the table using the IQY file without using excel?
I hope my question is understandable.
Thank you.
So I've found a way to overcome this problem. In the file data there's an href, that when opened by a browser will display the data in excel format. So I've used this data to get the information I needed.

Excel Macros with Javascript

I wish to manipulate excel spreadsheets using macros in Javascript rather than the default VBA. I can execute javascript code using the following VBA code
'javascript to execute
Dim b As String
b = "function meaningOfLife(a,b) {return 42;}"
'VBA tool to run it
Dim o As New ScriptControl
o.Language = "JScript"
o.AddCode b
MsgBox o.Run("meaningOfLife", 0, 1)
this enables me to execute arbitrary javascript, however I do not have access to the excel spreadsheet from within the javascript environment. Is there any way I can set and get worksheet values in the active worksheet from within javascript?
For people using Excel 2016 or later version, there is an Excel add-in called Funfun in the add-in store that actually allows you to write and run JavaScript code directly in Excel. And of course, your JavaScript code also has access to the data stored in the spreadsheet. Here is a screenshot of how it looks like in Excel
2016.
Well in the middle of the interface you have a section in which you could write JavaScript, CSS and HTML code. It is pretty much like a playground built into the Excel. But the Funfun also has an online editor in which you could test with your code. You could see it in the pic below. I also posted the link of the example in the first picture so you could play with.
https://www.funfun.io/1/#/edit/5a4e0d461010eb73fe125c4e
What is special about the Funfun online editor is that it contains a 'spreadsheet' just like Excel. Though you can't actually do any formatting in here, you could copy your data into the cells and test your code directly.
To use the data stored in the spreadsheet, all you need to do is to write some configuration in the short.io file of Funfun to tell JavaScript which area in the spreadsheet that contains your data. For example, in the example that I posted, all you need to write is
{
"data": "=A2:B9"
}
And in the JavaScript code, an object called $internal is used to read the data. So in order to read the data that stored in A2:B9, you need to write
var data = $internal.data;
And its done. You could go to the documentation of Funfun if you want to know more.
If you are satisfied with the result you achieved in the online editor, you could easily load the result into you Excel using the URL above. Of couse first you need to insert the Funfun add-in from Insert - My add-ins. Here are some screenshots showing how you could do this.
Disclosure: I'm a developer of Funfun
It depends what sort of "Excel programming" you want to do.
If you want to manipulate Excel files, you can do so via COM automation, or even ODBC to some degree, using JavaScript running under the Windows scripting environment.
But if you want to have your code running within an active Excel session doing things the visitor will see, you have fewer options.
See this question I posted a few years back when I had some JavaScript I wanted to run within Excel and didn't have the budget to convert to VBA:
How can I use JavaScript within an Excel macro?

How to display excel chart in browser?

I have an excel sheet containing excel chart. I am able to display entier excel sheet on browser using an iframe. However, I only want to display the chart present inside the excel sheet on the browser.
How do I achieve this? I see that it needs Javascript + ActiveX APIs. I tried but couldn't get it to work.
Please see code given below. It doesn't work as I am not able to set data attribute of "object" tag dynamically. It doesn't allow.
<object id="objFrame" data="" type="application/vnd.ms-excel"></object>
<script>
var Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
document.getElementById("objFrame").data = Excel.Workbooks.Open("Test.xls").Sheets("Chart1");
Excel.Quit();
</script>
Is there any other way to achieve this? Please post sample code. Thanks.
You should check this tool out, I believe this will achieve exactly what you're looking for, without having to load the memory bloat/leak known as the Office COM server, into browser memory, and feel like your violating security best practices.
SpreadsheetGear for .NET provides the ability to load Excel workbooks, plug in values, calculate and then render a chart (or a range of cells which contain a chart) on the server which can then be displayed in the browser. You can see live ASP.NET (C# and VB) samples here.
Disclaimer: I own SpreadsheetGear LLC
You might want to check the Funfun Excel add-in. Basically, Funfun allows you to use JavaScript directly in your Excel as the image below shows.
Here I have a sample chart which is plotted using HighChart.js with data in the spreadsheet. You could see the chart at the right side of your Excel. You could then click the button at the left-top corner of the chart to open the chart in default browser. Which looks like this.
Also, if you want to show both the spreadsheet and the chart in the browser. You have two option.
The first is to use Excel online. Then you have the same thing on your browser as in your local Excel.
As for the second option, Funfun also has an online editor in which you could explore with your JavaScript code alongside with your data.
You could check the detailed code of this example on the link below.
https://www.funfun.io/1/edit/5a439b96b848f771fbcdedf0
Disclosure: I'm a developer of Funfun

Categories