Skip to content

neogenia-jp/RemotePOI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RemotePOI

RemotePOI is a gRPC service that provides for the manipulation of xls/xlsx files using NPOI.

日本語版

Quick start

Starting the Service.

You can use a Docker container to start a service.

cd /path/to/this/repository
docker build -t rpoi_svc ./XlsManiSvc/
docker run -ti -p 37722:80 -v ${PWD}/sample_template:/mnt rpoi_svc

The container is now up and the gRPC service is waiting on port number 37722. We are hosting it using the ASP.NET Core gRPC service.

Running the Sample Client.

The ruby_client/ directory contains sample code for a client written in Ruby.

The sample is to open a file sample_template/est_template.xls, set values in some cells and save them, and so on. You can do this in the following way (Replace 192.168.1.158 with host's address of the service is running).

gem install grpc grpc-tools
cd ruby_client/
ruby ./rpoi_client.rb '192.168.1.158:37722' /tmp/sample.xls

Now the file should be saved to /tmp/sample.xls.

Multi-session mode.

Multi-session mode is enabled by setting the environment variable ENABLE_MULTI_SESSION when the service is started. When not in multi-session mode, the service will not be able to distinguish between multiple sessions when a user tries to access the service from a single source. You should always use multi-session mode if you expect parallel access to the service.

On the client side, the service gives you an HTTP header x-session-id when you access the service for the first time, so you need to add it to your request on the second and subsequent accesses.

The above sample is in ruby_client/rpoi_client2.rb, and you can find it in The following is an example. It is designed to open two sessions simultaneously from the same access source (IP address and port number) to perform file operations in parallel.

You can do this as follows:

Starting the service

docker build -t rpoi_svc ./XlsManiSvc/
docker run -ti -p 37722:80 -v ${PWD}/sample_template:/mnt -e ENABLE_MULTI_SESSION=1 rpoi_svc

Run the sample client

ruby ./rpoi_client2.rb '192.168.1.158:37722' /tmp/sample.xls

How to regenerate the gRPC definition

NET, it is automatically regenerated at build time.

For Ruby clients, you can regenerate it with the following commands

grpc_tools_ruby_protoc -I../XlsManiSvc/XlsManiSvc/Protos --ruby_out=lib --grpc_out=lib ../XlsManiSvc/XlsManiSvc/Protos/rpoi.proto

Appendix.

Useful links on handling HTTP headers in gRPC.