Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible in VBA convert Excel table to json

Tags:

json

excel

vba

I need convert data from excel table with about twenty columns and a lot of rows into json. I don't found a short example of code for this purpose in vba. I found this one https://github.com/VBA-tools/VBA-JSON/blob/master/JsonConverter.bas , but it is very large. May be it is a shorter example?

like image 221
Sharunas Bielskis Avatar asked Sep 07 '25 12:09

Sharunas Bielskis


1 Answers

I'd go with modified version of this one: http://www.excelvbamacros.in/2015/01/export-range-in-jason-format.html

if you want to write it to file there's a code:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")

Dim Fileout As Object
Set Fileout = fso.CreateTextFile("C:\some_dir\mydata.json", True, True)
Fileout.Write jsonStringFromConvertFunction
Fileout.Close
like image 80
adomas.m Avatar answered Sep 10 '25 02:09

adomas.m