by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 years ago )

foreword

Excelify is a set of Excel data conversion tools developed by me using Laravel. This tool, the current record,
I have successfully used this tool to transfer the Excel files authorized by the Ministry of Education to the public. There are about 160,000 entries in the dictionary and more than 5,000 entries of idioms.
Convert to the SQL format I need.

Function

Then Excelify mainly has three functions to convert and process Excel data.

1. Converter: (conversion)
Convert Excel table data to other formats,
Currently convertible formats include QueryBuilder, Json, Array, SQL, and Excel.
Because of the MVC architecture, render is performed through Laravel's Blade template,
So we can easily expand more conversion formats,

Conceptually, it is to convert the table data obtained from the Excel file to Array, and at the same time change the abcde English field name
Convert it into a meaningful name, and then throw it to the blade template to produce the conversion format I want.

For example, the following is the SQL data format, as you can see, this is a sample of Blade:
https://github.com/DevinY/excelify/blob/master/src/views/data_templates/sql.blade.php

By uploading the Excel file, by setting the range, such as a2~n60000, and creating the corresponding fields,
For example: a is name, b is address, c is tel
With the function corresponding to this field, we can directly import the exported SQL data into the database.

Two, Excelify: (Excelization)
At the beginning, I wanted to build something that could quickly convert the Table on the web page into Excel, so this function was born
Through this tool, he can grab all the Tables in the pages on the Internet and convert the Tables into Excel.
You may be curious, can HTML tables generated by JavaScript be captured?
Yes, it is possible, because Excelify I directly integrated Rendertron launched by Goolge,
Therefore, even if the Table of the page generated by Javascript is serialized by Rendertron, it can still produce Excel.

3. APIs
The second trick needs to be done manually, so I want to create a function that can be called by the program.
Let us convert the Table on the HTML page into an Excel file by using a program call.

question

Although Excelify provides a Docker version, it can be quickly searched, installed and started through Kametic, and can be deleted when not in use.
But not everyone has Docker, or knows how to use Docker.
Maybe you already have Laravel running on your computer, in order to use the Excelify function,
Is it too big to install another set of Laravel? The main source code of Excelify is only two Classes.
If you want to directly integrate the conversion function of Excelify into the existing project, it seems a bit troublesome.
Several files have to be changed.

So, I have long wanted to rewrite some of my Laravel Projects into Packages,
So, let's take a small Excelify repo and try it out.

For those who have surgery for the first time, it takes about half a day, let me convert him to a Laravel package,
The process is quite smooth, while rewriting and reading files to learn, after completion,
I found that writing the Laravel Package was unexpectedly simple. Of course, the converted Source still has a lot of room for optimization.

This is my first attempt to change a Laravel project to a Laravel suite,
So it's not perfect in some places, but I'd say It's work.

The whole process went smoothly without any major problems.
My approach is to look at other people's Package writing, and then rewrite it as my own.
Of course, read the documents on Laravel's official website at the same time.

Excelify notes:

If you are converting a large file, you must pay attention to the configuration in php.ini, otherwise Excelify cannot run normally.
upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 0
memory_limit = -1

Please set the memory to -1, no limit.

If you just want to transfer data and have Docker, it is a good choice to execute excelify through Docker.
I have already set php.ini because of the Container, and there is no problem with a large Excel file of 20~30MB.

Conclusion:

I don't use Excelify very often,
Because I don't turn things around or test Excelify functions for a long time all day long.

I only think of using him when I need to do conversions,
And he did solve several data conversion problems for me (including the dictionary database of Line Bot below),

But I do not guarantee the correctness of the data transferred by this tool in your environment,
Does it meet your expectations, so if you want to use it, please pay attention to the results after data conversion,
Of course, if you find any problems, please open a PR to me.

The more people use it, the more I can understand the problems and then optimize it.
If you also like this suite, welcome to fork to help me optimize it.

Install the Excelify suite:

https://packagist.org/packages/deviny/excelify

Here is my Line Bot for practice:

If you want to invite this robot to join the group: welcome to add him as a friend.
This is a dictionary with a library of 160,000 characters. It understands idioms and can tell stories!


Ministry of Education Mandarin Dictionary Public Authorization Network:
http://resources.publicense.moe.edu.tw/

 

Tags: product

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments