WorksheetAppend
Appends data as a new Worksheet to a Microsoft Excel Workbook
- Stored Procedure
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
EXEC SQLHTTP.net.WorksheetAppend @WorkbookPath, @SheetName, @GlobalTableName
Name | Type | Description |
---|---|---|
@WorkbookPath | nvarchar(4000) | The path to a Microsoft Excel Workbook |
@SheetName | nvarchar(4000) | Name of Worksheet to be added to the above Workbook. Default: Sheet1 |
@GlobalTableName | varchar(100) | Name of a Global Temporary Table that has been created and populated with data |
SQL Server 64 Bit Instances: This function requires the “Microsoft Access Database Engine 2010 Redistributable.” Please see the following for more information: https://www.microsoft.com/en-us/download/details.aspx?id=13255
The following example creates and populates a global temporary table called ##Temp which is subsequently appended to an Excel Workbook as a new Worksheet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
SET NOCOUNT ON DECLARE @WorkbookPath varchar(MAX) DECLARE @SheetName varchar(100) DECLARE @GlobalTableName varchar(100) SET @WorkbookPath = 'C:\ThisFolderExists\OLEDBProviders.xlsx' SET @SheetName = 'SampleSheet' SET @GlobalTableName = '##Temp' SELECT CAST([Provider] AS varchar(255)) AS [Provider], CAST(ProgId AS varchar(255)) AS ProgId, Is32Bit INTO ##Temp FROM SQLHTTP.net.OLEDBProviders EXEC SQLHTTP.net.WorksheetAppend @WorkbookPath, @SheetName, @GlobalTableName DROP TABLE ##Temp |
1 2 3 |
Command(s) completed successfully. |