Click here to Skip to main content
15,122,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

Part of my application involved uploading datasheets via a web portal. The sheets can be in any spreadsheet format.

My app uses predefined 'plugins' to translate these datasheets into a flat format that is easier to manipulate into our data structure.

Some of these files can be huge (well, many Mb) which takes a few minutes to upload depending on the upload speed. Some files (one in particular) also take a looong time to flatten.

I would love to start processing the file by reading the stream as soon as they start uploading.

This works fine for csv, but xls and xlsx files can't be processed until the file is fully uploaded, opened and converted into a standard object[][] ready for flattening.


So, my question: Is there any way I can process the file on the clients machine via client-side code? I would need to open the file and save one or many sheets as csv then upload them.

Is this possible? Maybe I can create a plugin for chrome? I'd rather not need to install anything.

Sorry if this sounds a bit ridiculous, but I know I'm behind the times on tech so I was hoping that there was some way.

Thanks
Andy ^_^

What I have tried:

I'll show you my upload stream code:
C#
var file = context.Request.Files[i];
byte[] input = new byte[file.ContentLength];

var stream = file.InputStream;

stream.Read(input, 0, file.ContentLength);

if (!importedFiles.ContainsKey(file.FileName))
    importedFiles.Add(file.FileName,null);
importedFiles[file.FileName] = new FileImportWizardItem
{
    Name = file.FileName,
    Size = file.ContentLength,
    DateTime = DateTime.Now,
    File = input
};

//update the client
RateTicker.NotifyFileImported(context, file.FileName, file.ContentLength);

ConvertFile(context, supplierId, importedFiles[file.FileName]);
Posted
Comments
Nelek 8-Nov-16 8:16am
   
I can't give you an answer, but I want to say you thanks: You are asking a decent question :) (pity it is so sporadic to see such)
Mehdi Gholam 8-Nov-16 9:33am
   
CSV files are uncompressed and XLSX files are more compact for the same data, so it would not be a good idea.

Also even if you could start on the client, what about connection failures and retry... , which would make your job harder.
Andy Lanng 8-Nov-16 9:36am
   
CSV is uncompressed but that allows be to start processing them during their upload instead of after.

I know it would make my job harder, but requirements are rarely there to make my job easier :Þ

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900