Giter Site home page Giter Site logo

azure-samples / storage-blobs-dotnet-export-import-excel-blob-to-from-db Goto Github PK

View Code? Open in Web Editor NEW
1.0 204.0 10.0 208 KB

This sample demonstrates how to import the worksheet Azure Excel file blob to DB on the Azure SQL Server and how to export from DB to Azure Excel blob.

License: MIT License

C# 5.85% ASP 0.05% JavaScript 94.09%

storage-blobs-dotnet-export-import-excel-blob-to-from-db's Introduction

services platforms author
blobs
c#
msonecode

How to Import/Export Azure Excel file to/from Azure SQL Server in ASP.NET

This sample demonstrates how to import the worksheet Azure Excel file blob to DB on the Azure SQL Server and how to export from DB to Azure Excel blob.

Running this sample

Do one of the following to start debugging:

  1. Click the Start Debugging button on the toolbar.
  2. Click Start Debugging button in the Debug menu.                                                                                  
  3. Press F5.
  • You will see the web page of this application.

  • Then click button "Export to Excel".

  • Click button "Import to DB" on the page.

  • You can click the button "Clear Log" to clear the logs.

About the code

Before you build the project, make sure you have installed WindowsAzure.Storage package in the project.
The following steps can help you with the installation:

  1. Open the solution CSWebAppAzureExcelImportExport.sln.
  2. Right click the project and select [Manage NuGet Packages...].
  3. Search WindowsAzure.Storage at the Browse tab page. Find the right package and then install it.

You also need to set your Azure information in Helper.cs file:

StorageCredentials cred = new StorageCredentials("[Your storage account name]", "[Your storage account key]");
CloudBlobContainer container = new CloudBlobContainer(new Uri("http://[Your storage account name].blob.core.windows.net/[Your container name] /"), cred);
string connectionStr = "Azure SQL Server Connection String";

Run CreateTable.sql in the SQLScripts folder on your Azure SQL Server DB to create test table and test data, or you can set your data table info first in Helper.cs file if you want to test your own data:

List<string> columns = new List<string>() { "{column1}", "{column2}", "{column3}"};
string tableName = "{table name}";

More information

See more about this sample: https://code.msdn.microsoft.com/How-to-ImportExport-Azure-0c858df9
For more information about Open XML, see https://msdn.microsoft.com/en-us/library/office/bb456488.aspx
About Azure SQL Database development, see https://azure.microsoft.com/en-us/documentation/articles/sql-database-develop-overview/
To learn more about SqlBulkCopy class, see https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy(v=vs.110).aspx

storage-blobs-dotnet-export-import-excel-blob-to-from-db's People

Contributors

acomsmpbot avatar aliceqin12 avatar msonecode avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.