# Excel Quick Load

## Data Load

Need to take your Excel data and load it into your database to get the analysts started?  &#x20;

Instead of taking weeks to develop a new data pipeline, create structure, and work with the business to load your new client data in, just drop the file in Perigee. We will take care of everything from finding and getting the data loaded, to creating a table in only a few seconds. You’ll be a hero!  &#x20;

#### The Data

Here's a typical messed up Excel file where data is shifted and there are unwanted headers.&#x20;

<div data-full-width="true"><figure><img src="https://2203366127-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FloJjRj49SSQfSrp7vuw9%2Fuploads%2FxUmc8moZgFogSykcVEJ7%2Fimage.png?alt=media&#x26;token=71108d42-df2c-4c33-92dd-346177f8f547" alt="Excel window showing misaligned data"><figcaption></figcaption></figure></div>

#### The Code

```csharp
using Microsoft.Extensions.Logging;
using Perigee;
using Perigee.Database.MSSQL;
using Perigee.FileFormats.Excel;
using System.Data;

// Visit https://docs.perigee.software to learn more
// Visit https://perigee.software to purchase a license!
PerigeeApplication.App("Excel Load", (c) =>
{
    //Register the "main" connection string to a credential called MSSQL.
    c.RegisterConnectionString("MSSQL", "main");
    
    c.Add("ReadFile", (ct, l) =>
    {
        //Get data from file, sheet 1.
        var tbl = Transformer.TableFromFile("SampleExcel.xlsx", sheetIndex: 1);
        tbl.TableName = "ClientData";
        
        //Load into SQL
        tbl.ProcessToSQL("MSSQL");

        //run once. 
        while (PerigeeApplication.delayOrCancel(10000, ct)) {}
    });
});
```

Taking a peak at our database, we see the data loaded into our new table **`dbo.clientData`**:

<div data-full-width="true"><figure><img src="https://2203366127-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FloJjRj49SSQfSrp7vuw9%2Fuploads%2FY1PibqfjP7QzDEseieu9%2Fimage.png?alt=media&#x26;token=2ed32b57-fd41-4ca8-913b-e86379dca4d4" alt=""><figcaption></figcaption></figure></div>

Which came directly from the Excel file linked below

### The associated files:

The <mark style="color:orange;">**`appsettings.json`**</mark> file:

```json
{
  "ConnectionStrings": {
    "main": "data source=host; initial catalog=test; User Id=sa; Password=abc"
  },
  "AppSettings": {
  
  },
  "Perigee": { "HideConsole": false },
  "Serilog": {
    "MinimumLevel": "Debug",
    "WriteTo": [
      { "Name": "Console" }
    ]
  }
}
```

The <mark style="color:orange;">**`SampleExcel`**</mark> file we loaded:

{% file src="<https://2203366127-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FloJjRj49SSQfSrp7vuw9%2Fuploads%2FKFnWdfNtZBflvkSouv9G%2FSampleExcel.xlsx?alt=media&token=4ea076fb-88a6-4f23-93cd-d93cbe89997c>" %}
