Export data from the database to Excel

To export the data to an Excel spreadsheet on the first data should check out.
Due to the convenient export data back to Excel spreadsheet I write my own inquiries shots out of
Here Insert Picture Description
the query after the data is screening out of here I will not write code data filter data, the next step would directly create a workbook to receive data, here create a workbook, the workbook is equivalent to create an Excel table
Here Insert Picture Description
then you've created a workbook have to create worksheets in a workbook inside, this is equivalent to a worksheet in Excel table inside the child table is created.
Here Insert Picture Description
Then is to create the header line
Here Insert Picture Description
to create a finished header row can know the header row is not at this time the data you need to set the header data of the
Here Insert Picture Description
set after the expiry of the header is straight as a table spread data of
a table to transfer data with The for loop can, where each row of data to create a complete transfer line.
Here Insert Picture Description
After creating the Excel spreadsheet is named as an Excel spreadsheet
Here Insert Picture Description
to create a memory stream after
Here Insert Picture Description
then excel write memory stream which
Here Insert Picture Description
is then written to a specified memory current Excel spreadsheet flow position
Here Insert Picture Description
and then spread to the memory pages on it
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_44486126/article/details/89927474