Skip to content

cienciadedadosebigdata/bootstrapExcelExport

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

bootstrapExcelExport

Bootstrap plugin to export html tables to excel

Bootstrap Export Table to Excel Plugin

What is this ?

This is a simple usage plugin to export HTML <table> to excel files. In fact, alow user to save html data to disk as a .xls file. It was developed with Twitter Bootstrap in mind, but you can use with regular html tables instead.

It´s based on Batta Tech Excel Export, but a bit more simple.

You can try a demo here

How to use

First of all, you need a HTML <table> decorated or not with bootstrap css table, table-striped, etc. Then, create a link using <a> tag. Again, you can decorate or not with bootstrap commom button look and feel css for <a> links using btn btn-default. At last, Use the <a> selector to determine plugins behavior on button click.

Let´s see some pieces of code...

Code

1.Include the plugin in your html. Of course, you must have jquery previously loaded - it´s a bootstrap plugin, remember ?

<script src='fg1998/jquery-bootstrapExportExcel.js'></script>

2.Create a table markup adding follow code like this :

  <table class='table table-bordered' id='tblExample'>
      <thead>
          <tr>
              <th>#</th>
              <th>Column heading</th>
              <th>Column heading</th>
              <th>Column heading</th>
          </tr>
      </thead>
      <tbody>
          <tr>
              <th scope="row">1</th>
              <td>Column content</td>
              <td>Column content</td>
              <td>Column content</td>
          </tr>
          <tr>
              <th scope="row">2</th>
              <td>Column content</td>
              <td>Column content</td>
              <td>Column content</td>
          </tr>
          <tr>
              <th scope="row">3</th>
              <td>Column content</td>
              <td>Column content</td>
              <td>Column content</td>
          </tr>
          <tr>
              <th scope="row">4</th>
              <td>Column content</td>
              <td>Column content</td>
              <td>Column content</td>
          </tr>
      </tbody>
  </table>

3.Create a <a> link for click and save

    <a id='btnExport' class='btn btn-primary'>Click me for save<a>                  

4.Use the <a> selector to connect with plugin. Don´t you forget to inform table id !

  $('#btnExport').bootstrapExcelExport({ tableSelector : '#tblExample' });

Options

Attention - all options are in lower camel case.

Property Required Description
tableSelector required This is the table identifer. You can use any jQuery compliance selector
fileName optional Use this to change default name of downloade file. The default is download.xls. Dont forget to include the extension .xls.
worksheetName optional Change the excel worksheet name. Default is My Worksheet
encoding optional Default is utf-8. Change to encoding you need if necessary

Useful links

Bootstrap - The most popular HTML, CSS and JS Framework for developing responsive, mobile first projects on the web.

jQuery - jQuery is a fast, small, and feature-rich JavaScript library.

Battatech excelexport - Very useful and rick tool to export HTML tables to excel.

Compatibility

List of tested and compatibility browsers

Browser Version tested Compatibility
Chrome 40 Compatible
Firefox 34 Compatible
Opera 26 Compatible
Safari 5 Not compatible
Internet Explorer 11 Not compatible

License

Coded by fg1998

I really don´t know much about license. I believe the Apache.org Version 2.0 is enough for everyone. In feel words, you can use, copy, modify, etc whatever you want. I hope this piece of software cand be useful for you. If you need some more, please let me know.

http://www.apache.org/licenses/LICENSE-2.0

I found this text and I believe it is important...

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Bootstrap plugin to export html tables to excel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 100.0%