Excel to Json ASPX Upload

Hello,
      I’m not sure if this is possible. I’m making a Website for my support team using the Twitter Bootstrap framework. (Since I don’t have alot of mad web skills)
What I’m trying to do is create a upload page that a tech can update an excel file (once a month) with data from are Mobile phone vendors.  I was hoping that I can find an script that would upload and convert it to a json file that would be located on directory. This way I can use that Json file with the Bootstrap autocomplete function.

Is this possible or should I be looking into something else.  TO be honest I just want to get this setup for the team so they can manage it going forward. That why I never have to update or play with the data for them to get the webpage to work.


Example of CVS:  >
Sprint;555-444-1111,04/25/1900
Sprint;555-444-2222,04/25/1911
AT&T;555-444-3333,04/25/1912
And so on….

Note: I'm using IIS 7.5, Domain access only.
POOK-101Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jitendra PatilSr.Software EngineerCommented:
try the below links
C# CODE TO CONVERT CSV FILE JSON FILE FORMAT
{DELETED LINK TO COMPETING SITE THAT ALSO DID NOT PROVIDE AN CONCLUSIVE ANSWER - tagit (TA)}
hope this helps.
0
RobOwner (Aidellio)Commented:
In referencing the link given above re C# to convert CSV, you would need your users to save the spreadsheet as a CSV file, which is easy enough with a bit of training.  It would mean that only one sheet in the spreadsheet can be saved at a time so if an Excel doc has 3 sheets with data, they would have to upload 3 CSV files.

Then use the C# code given (untested):

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Newtonsoft.Json;
using System.Data;
using System.Text.RegularExpressions;

namespace jsonPractice
{
  
    class Program
    {
        static void Main(string[] args)
        {
            string[] cols;
            string[] rows;
          
            StreamReader sr = new StreamReader(@"F:\Sample.csv");  //SOURCE FILE
            StreamWriter sw = new StreamWriter(@"F:\sample.json");  // DESTINATION FILE
          
            string line = sr.ReadLine();
          

            cols = Regex.Split(line, ",");

            DataTable table = new DataTable();
            for (int i = 0; i < cols.Length; i++)
            {
                table.Columns.Add(cols[i], typeof(string));
            }
            while ((line = sr.ReadLine()) != null)
            {
                 table.Rows.Clear();
              
                int i;
                string row = string.Empty;
                rows = Regex.Split(line, ",");
                DataRow dr = table.NewRow();
              
                for (i = 0; i < rows.Length ; i++)
                {
                    dr[i] = rows[i];
                                    
                }
                table.Rows.Add(dr);
              
                string json = JsonConvert.SerializeObject(table, Formatting.Indented);
                sw.Write(json);
            }

        
            sw.Close();
            sr.Close();

        }
    }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rainer JeschorCommented:
Hi,
it depends: if they all use the same template / same structured Excel file and it is at least Excel 2007 file type (.xslx), you might be able to use Office Open XML 2 to open and process the uploaded Excel file and extract the data and store it as CSV (there is no built-in function to "SaveAsCSV") or even directly process the rows/cells to create the JSON file.
Pro: pure .NET with no need to install Excel (client) on the server

HTH
Rainer
0
POOK-101Author Commented:
This got me going in the right direction. Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.