Azure Blob 저장소에있는 Excel 통합 문서에있는 데이터를 가져 오려고합니다. 또한 Excel 파일이 매일 수동으로 업데이트 된 다음 MS Flow를 통해 Blob 저장소로 내보내집니다. 그 데이터를 Azure SQL 데이터베이스의 일부 테이블로 내 보냅니다. 너무 비싸서 SSIS 패키지를 사용할 수 없습니다. 누구나 SSIS없이이 작업을 수행 할 수있는 방법을 알고 있습니까? OPENROWSET과 연결된 서버를 살펴 보았지만 둘 다 "내 SQL Server 버전에서는 지원되지 않습니다." 나는 또한 Excel 파일을 CSV로 변환 한 다음 ADF를 사용하는 것으로 생각했지만 블로 브에서 CSV로 변환하는 방법을 알아 내지 못했습니다 ... (수동으로 업로드하지 않고)Excel to SQL 표
0
A
답변
1
나는 또한 Excel 파일을 CSV로 변환 한 다음 ADF를 사용하는 것으로 생각했지만 블로 브에서 CSV로 변환하는 방법을 알아 내지 못했습니다 ... (수동으로 업로드하지 않고)
설명에 따르면 귀하의 요구 사항을 달성 azure webjob 또는 azure 기능을 사용하려고 할 수 있습니다.
이 두 가지 서비스를 사용하면 BLOB 트리거 (새 파일을 BLOB에 추가 할 때) 또는 시간 트리거 (매일 함수를 트리거)를 사용하여 blob 저장소에서 azure sql로 데이터를 내보내는 기능을 실행할 수 있습니다 직접 데이터베이스.
자세한 내용은 아래 코드 (웹 작업 코드) 및 문서를 참조 수 :
Webjob blobtrigger, webjob timer trigger을.
// Nuget 패키지에서 DocumentFormat.OpenXml을 설치하십시오. 공용 클래스 기능 {
public static string GetCellValue(SpreadsheetDocument document, Cell cell)
{
SharedStringTablePart stringTablePart = document.WorkbookPart.SharedStringTablePart;
string value = cell.CellValue.InnerXml;
if (cell.DataType != null && cell.DataType.Value == CellValues.SharedString)
{
return stringTablePart.SharedStringTable.ChildElements[Int32.Parse(value)].InnerText;
}
else
{
return value;
}
}
public static void ExportExcelToDatabase ([BlobTrigger("excel/testexcel.xlsx")] Stream blobStream, TextWriter log)
{
log.WriteLine("Start export excel to azure sql database");
string connectionStr = "{sql database connection string}";
//This is the excel table column name
List<string> columns = new List<string>() { "Name", "Class", "Score", "Sex" };
string tableName = "StudentScore";
DataTable dt = new DataTable();
using (SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(blobStream, false))
{
WorkbookPart workbookPart = spreadSheetDocument.WorkbookPart;
IEnumerable<Sheet> sheets = spreadSheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>();
string relationshipId = sheets.First().Id.Value;
WorksheetPart worksheetPart = (WorksheetPart)spreadSheetDocument.WorkbookPart.GetPartById(relationshipId);
Worksheet workSheet = worksheetPart.Worksheet;
SheetData sheetData = workSheet.GetFirstChild<SheetData>();
IEnumerable<Row> rows = sheetData.Descendants<Row>();
foreach (Cell cell in rows.ElementAt(0))
{
dt.Columns.Add(GetCellValue(spreadSheetDocument, cell));
}
foreach (Row row in rows.Skip(1))
{
DataRow tempRow = dt.NewRow();
for (int i = 0; i < row.Descendants<Cell>().Count(); i++)
{
tempRow[i] = GetCellValue(spreadSheetDocument, row.Descendants<Cell>().ElementAt(i));
}
dt.Rows.Add(tempRow);
}
}
//Bulk copy datatable to DB
SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionStr);
try
{
bulkCopy.DestinationTableName = tableName;
columns.ForEach(col => { bulkCopy.ColumnMappings.Add(col, col); });
bulkCopy.WriteToServer(dt);
}
catch (Exception ex)
{
throw ex;
}
finally
{
bulkCopy.Close();
}
log.WriteLine("End export excel to azure sql database");
}
}
관련 문제
- 1. SQL to Mimic Excel
- 2. Oracle SQL to Excel - 통합
- 3. Excel to SQL, C# 라이브러리
- 4. DateTime 변환 오류 - Excel to SQL
- 5. scrape to excel file
- 6. VBA Excel to SqlServer
- 7. Excel 표 정규화
- 8. Excel 표 값 변경
- 9. Word - Excel 표 캡션
- 10. Excel to SQLite to android
- 11. Ms access excel to excel
- 12. interop를 사용하여 Excel to Excel
- 13. mysql query to excel
- 14. 표 SQL
- 15. 표 SQL
- 16. C# Interop Excel 형식과 Excel 형식 (표)
- 17. Excel VBA로 HTML 표 생성
- 18. XML to Excel 매핑
- 19. Excel vba to mac
- 20. Java to Excel 2010
- 21. Gridview to Excel 문제
- 22. TreeNode export to excel
- 23. RadGrid export to excel
- 24. XML to CSV/Excel
- 25. html to excel 내보내기
- 26. Datetet to excel
- 27. Excel to C#
- 28. jquery datatables to excel
- 29. XML to excel error
- 30. deedle frame to excel
은 왜 SSIS는 비용이 많이 드는 건가요? – FLICKER