Reading Excel Files as a Server Process

Reading Excel Files as a Server Process

There were a number of libraries that were highlighted by different users that would allow the sort of functionality required. I've listed them here and some of these were evaluated so where appropriate I've tried to put down interesting comments for comparing them. The details I've included are completely opinion based, however any of these libraries would probably achieve the required goal.

SpreadsheetGear.Net

(Didn't evaluate due to high purchase cost)

Aspose.Cells

(Evaluated by a collegue. Appeared to be fairly simple to implement, performance comparable to Excel Interop).

GemBox

(Didn't evaluate)

Excel Services

(Seems only to be included in SharePoint 2007)

Excel Mapper
(Didn't evaluate because it requires strongly typed objects to import into which didn't fit my requirement).

SmartXls

(Didn't evaluate because it requires strongly typed objects to import into which didn't fit my requirement).

ActiveXls

(Fairly easy to use, lack of Properties raises questions, they have a preference of Methods for trivial actions. Despite it's claim of 1M records a second was out performed by cheaper FlexCel. Have decided that the help/API manual is almost useless.)

Koogra

(Didn't evaluate due to finding no documentations/information)

FileHelpers

(Didn't evaluate)

Flexcel
(Lowest cost solution found, good performance and was simple to implement with a close proximity to Excel Interop structure. Also received quick response to technical question from support. Probably my pick of the bunch.)

SyncFusion BackOffice

(Medium cost and had a reasonable structure. Unfortunately had more difficulty implementing and inconsistent results when running unit tests. Also received a number of 'Attempted to read protected memory' errors, which didn't encourage me with purely managed library.)

read write excel file on server

Try Aspose Cells.

Best Library I know.

Reading Excel file using node.js

There are a few different libraries doing parsing of Excel files (.xlsx). I will list two projects I find interesting and worth looking into.

Node-xlsx

Excel parser and builder. It's kind of a wrapper for a popular project JS-XLSX, which is a pure javascript implementation from the Office Open XML spec.

node-xlsx project page

Example for parsing file

var xlsx = require('node-xlsx');

var obj = xlsx.parse(__dirname + '/myFile.xlsx'); // parses a file

var obj = xlsx.parse(fs.readFileSync(__dirname + '/myFile.xlsx')); // parses a buffer

ExcelJS

Read, manipulate and write spreadsheet data and styles to XLSX and JSON. It's an active project. At the time of writing the latest commit was 9 hours ago. I haven't tested this myself, but the api looks extensive with a lot of possibilites.

exceljs project page

Code example:

// read from a file
var workbook = new Excel.Workbook();
workbook.xlsx.readFile(filename)
.then(function() {
// use workbook
});

// pipe from stream
var workbook = new Excel.Workbook();
stream.pipe(workbook.xlsx.createInputStream());

Javascript Read Excel file on server with SheetJS

This worked for me

   /* set up async GET request */
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.responseType = "arraybuffer";

req.onload = function(e) {
var data = new Uint8Array(req.response);
var workbook = XLSX.read(data, {type:"array"});

/* DO SOMETHING WITH workbook HERE */
}

req.send();

reading excel server-side

Using Interop on the server is NOT supported by MS - see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

Since Windows Vista MS introduced several security-related measures which prevent a Windows Service from doing "desktop-like" things... which means you would have to circumvent several security measures to get it to work (NOT recommended!).

To deal with Excel in a server-scenario there are several options (free and commercial) out there:

I can recommend Aspose.Cells and Flexcel... didn't try SpreadsheetGear but hear+read lots of good things about it...

Free options (though for the newer xlsx format only!) are for example OpenXML 2 from MS and EPPlus.

Reading and writing Excel files using Ruby on a server without Excel installed

I agree with Gonzih, and I use roo fairly regularly. It allows me to read, write, and write using a template file.
The project is fairly well documented on their site.

I always use something like:

input = Excel.new(path)
output = Array.new
input.default_sheet = input.sheets[sheet]
start.upto(input.last_row) do |row|
output << input.row(row)
end

p output
=> a nested array representing the spreadsheat.

p output[0]
=> [row1_column_a, row1_column_b...]

to read a spreadsheet. note that the roo gem requires you to use Excelx.new instead of Excel.new if your file is a .xlsx.

to write you can:

book = Spreadsheet::Workbook.new
write_sheet = book.create_worksheet
row_num = 0
input.each do |row|
write_sheet.row(row_num).replace row
row_num +=1
end
book.write "/path/to/save/to.xls"

where input is an array structured just like output was

How to get the Data in right format When reading an Excel file from FTP Server

As stuartd pointed out. You are reading an excel file as a text file. If you want to read an excel file you need to add the Office.Interop.Excel references to the project and then to your classes. If you have excel on your machine you can do this without a problem. If you do not have excel you will have to find a third party library. I recently posted an answer explaining how to do this if excel is on your machine.

Linking Excel In C#

Once the reference is there you can access excel files properly.



Related Topics



Leave a reply



Submit