노트별 분리
This commit is contained in:
@@ -7,7 +7,7 @@ using Excel = Microsoft.Office.Interop.Excel;
|
||||
namespace DwgExtractorManual.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>۾<EFBFBD><DBBE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
/// Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>۾<EFBFBD><DBBE><EFBFBD> <20><><EFBFBD><EFBFBD>ϴ<EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
internal class ExcelDataWriter
|
||||
{
|
||||
@@ -19,14 +19,14 @@ namespace DwgExtractorManual.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Title Block <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD>
|
||||
/// Title Block <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>
|
||||
/// </summary>
|
||||
public void WriteTitleBlockData(List<TitleBlockRowData> titleBlockRows)
|
||||
{
|
||||
if (excelManager.TitleBlockSheet == null || titleBlockRows == null || titleBlockRows.Count == 0)
|
||||
return;
|
||||
|
||||
int currentRow = 2; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
int currentRow = 2; // <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
foreach (var row in titleBlockRows)
|
||||
{
|
||||
@@ -42,14 +42,14 @@ namespace DwgExtractorManual.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Text Entity <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD>
|
||||
/// Text Entity <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>
|
||||
/// </summary>
|
||||
public void WriteTextEntityData(List<TextEntityRowData> textEntityRows)
|
||||
{
|
||||
if (excelManager.TextEntitiesSheet == null || textEntityRows == null || textEntityRows.Count == 0)
|
||||
return;
|
||||
|
||||
int currentRow = 2; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
int currentRow = 2; // <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
foreach (var row in textEntityRows)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace DwgExtractorManual.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD>
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>
|
||||
/// </summary>
|
||||
public void WriteMappingDataToExcel(Dictionary<string, Dictionary<string, (string, string, string, string)>> mappingData)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ namespace DwgExtractorManual.Models
|
||||
if (excelManager.MappingSheet == null || mappingData == null)
|
||||
return;
|
||||
|
||||
int currentRow = 2; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
int currentRow = 2; // <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
Debug.WriteLine($"[DEBUG] Writing mapping data to Excel. Total files: {mappingData.Count}");
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
try
|
||||
{
|
||||
// <20><>ġ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20>迭 <20><><EFBFBD><EFBFBD>
|
||||
// <20><>ġ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20>迭 <20><><EFBFBD>
|
||||
object[,] rowData = new object[1, 6];
|
||||
rowData[0, 0] = fileName;
|
||||
rowData[0, 1] = mapKey;
|
||||
@@ -122,13 +122,13 @@ namespace DwgExtractorManual.Models
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"? <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>: {ex.Message}");
|
||||
Debug.WriteLine($"? <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Excel <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Excel <20><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> FileName<6D><65> AILabel<65><6C> <20><>Ī<EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD> ã<><C3A3> Pdf_value<75><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
||||
/// Excel <20><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> FileName<6D><65> AILabel<65><6C> <20><>Ī<EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD> ã<><C3A3> Pdf_value<75><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
||||
/// </summary>
|
||||
public bool UpdateExcelRow(string fileName, string aiLabel, string pdfValue)
|
||||
{
|
||||
@@ -159,13 +159,13 @@ namespace DwgExtractorManual.Models
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"? Excel <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><> <20><><EFBFBD><EFBFBD>: {ex.Message}");
|
||||
Debug.WriteLine($"? Excel <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><> <20><><EFBFBD><EFBFBD>: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD> (PDF <20>÷<EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
/// DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD> (PDF <20>÷<EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
/// </summary>
|
||||
public void SaveDwgOnlyMappingWorkbook(Dictionary<string, Dictionary<string, (string, string, string, string)>> mappingData, string resultFolderPath)
|
||||
{
|
||||
@@ -174,26 +174,26 @@ namespace DwgExtractorManual.Models
|
||||
string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
string savePath = System.IO.Path.Combine(resultFolderPath, $"{timestamp}_DwgOnly_Mapping.xlsx");
|
||||
|
||||
Debug.WriteLine($"[DEBUG] DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>: {savePath}");
|
||||
Debug.WriteLine($"[DEBUG] DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>: {savePath}");
|
||||
|
||||
var dwgOnlyWorkbook = excelManager.CreateNewWorkbook();
|
||||
var dwgOnlyWorksheet = (Excel.Worksheet)dwgOnlyWorkbook.Worksheets[1];
|
||||
dwgOnlyWorksheet.Name = "DWG Mapping Data";
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> (PDF Value <20>÷<EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
dwgOnlyWorksheet.Cells[1, 1] = "<22><><EFBFBD>ϸ<EFBFBD>";
|
||||
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD> (PDF Value <20>÷<EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
dwgOnlyWorksheet.Cells[1, 1] = "<22><><EFBFBD>ϸ<EFBFBD>";
|
||||
dwgOnlyWorksheet.Cells[1, 2] = "Map Key";
|
||||
dwgOnlyWorksheet.Cells[1, 3] = "AI Label";
|
||||
dwgOnlyWorksheet.Cells[1, 4] = "DWG Tag";
|
||||
dwgOnlyWorksheet.Cells[1, 5] = "DWG Value";
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8> <20><><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD> <20><>Ÿ<EFBFBD><C5B8> <20><><EFBFBD><EFBFBD>
|
||||
var headerRange = dwgOnlyWorksheet.Range["A1:E1"];
|
||||
headerRange.Font.Bold = true;
|
||||
headerRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGray);
|
||||
headerRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Է<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Է<EFBFBD>
|
||||
int totalRows = mappingData.Sum(f => f.Value.Count);
|
||||
if (totalRows > 0)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ namespace DwgExtractorManual.Models
|
||||
dwgOnlyWorksheet.Columns.AutoFit();
|
||||
excelManager.SaveWorkbookAs(dwgOnlyWorkbook, savePath);
|
||||
|
||||
Debug.WriteLine($"? DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD> <20>Ϸ<EFBFBD>: {System.IO.Path.GetFileName(savePath)}");
|
||||
Debug.WriteLine($"? DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD> <20>Ϸ<EFBFBD>: {System.IO.Path.GetFileName(savePath)}");
|
||||
|
||||
dwgOnlyWorkbook.Close(false);
|
||||
System.GC.Collect();
|
||||
@@ -235,17 +235,17 @@ namespace DwgExtractorManual.Models
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"? DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>: {ex.Message}");
|
||||
Debug.WriteLine($"? DWG <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Height <20><><EFBFBD>ĵ<EFBFBD> Excel <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
/// Height <20><><EFBFBD>ĵ<EFBFBD> Excel <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public void WriteHeightSortedData(List<TextEntityInfo> textEntities, Excel.Worksheet worksheet, string fileName)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
worksheet.Cells[1, 1] = "Height";
|
||||
worksheet.Cells[1, 2] = "Type";
|
||||
worksheet.Cells[1, 3] = "Layer";
|
||||
@@ -253,16 +253,16 @@ namespace DwgExtractorManual.Models
|
||||
worksheet.Cells[1, 5] = "FileName";
|
||||
worksheet.Cells[1, 6] = "Text";
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8> <20><><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD> <20><>Ÿ<EFBFBD><C5B8> <20><><EFBFBD><EFBFBD>
|
||||
var headerRange = worksheet.Range["A1:F1"];
|
||||
headerRange.Font.Bold = true;
|
||||
headerRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightBlue);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD> ExtractTextEntitiesWithHeight<68><74><EFBFBD><EFBFBD> <20>̹<EFBFBD> <20><><EFBFBD>ĵǾ<C4B5><C7BE><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20>ٽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>.
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD> ExtractTextEntitiesWithHeight<68><74><EFBFBD><EFBFBD> <20>̹<EFBFBD> <20><><EFBFBD>ĵǾ<C4B5><C7BE><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20>ٽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>.
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Է<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Է<EFBFBD>
|
||||
int row = 2;
|
||||
foreach (var entity in textEntities) // sortedEntities<65><73> textEntities<65><73> <20><><EFBFBD><EFBFBD>
|
||||
foreach (var entity in textEntities) // sortedEntities<65><73> textEntities<65><73> <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
worksheet.Cells[row, 1] = entity.Height;
|
||||
worksheet.Cells[row, 2] = entity.Type;
|
||||
@@ -275,5 +275,99 @@ namespace DwgExtractorManual.Models
|
||||
|
||||
worksheet.Columns.AutoFit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Note 엔티티들을 Excel 워크시트에 기록합니다 (기존 데이터 아래에 추가).
|
||||
/// </summary>
|
||||
public void WriteNoteEntities(List<NoteEntityInfo> noteEntities, Excel.Worksheet worksheet, string fileName)
|
||||
{
|
||||
if (noteEntities == null || noteEntities.Count == 0)
|
||||
{
|
||||
Debug.WriteLine("[DEBUG] Note 엔티티가 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 현재 워크시트의 마지막 사용된 행 찾기
|
||||
Excel.Range usedRange = null;
|
||||
int lastRow = 1;
|
||||
|
||||
try
|
||||
{
|
||||
usedRange = worksheet.UsedRange;
|
||||
lastRow = usedRange?.Rows.Count ?? 1;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[DEBUG] UsedRange 접근 오류, 기본값 사용: {ex.Message}");
|
||||
lastRow = 1;
|
||||
}
|
||||
|
||||
int startRow = lastRow + 2; // 한 줄 띄우고 시작
|
||||
Debug.WriteLine($"[DEBUG] Note 데이터 기록 시작: {startRow}행부터 {noteEntities.Count}개 항목");
|
||||
|
||||
// Note 섹션 헤더 추가 (간단한 방식으로 변경)
|
||||
try
|
||||
{
|
||||
worksheet.Cells[startRow - 1, 1] = "=== Notes ===";
|
||||
worksheet.Cells[startRow - 1, 2] = "";
|
||||
worksheet.Cells[startRow - 1, 3] = "";
|
||||
worksheet.Cells[startRow - 1, 4] = "";
|
||||
worksheet.Cells[startRow - 1, 5] = "";
|
||||
worksheet.Cells[startRow - 1, 6] = "";
|
||||
|
||||
// 헤더 스타일 적용 (개별 셀로 처리)
|
||||
var headerCell = worksheet.Cells[startRow - 1, 1];
|
||||
headerCell.Font.Bold = true;
|
||||
headerCell.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightYellow);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[DEBUG] Note 헤더 작성 오류: {ex.Message}");
|
||||
}
|
||||
|
||||
// Note 데이터 입력 (배치 방식으로 성능 향상)
|
||||
int row = startRow;
|
||||
try
|
||||
{
|
||||
foreach (var noteEntity in noteEntities)
|
||||
{
|
||||
worksheet.Cells[row, 1] = 0; // Height는 0으로 설정
|
||||
worksheet.Cells[row, 2] = noteEntity.Type ?? "";
|
||||
worksheet.Cells[row, 3] = noteEntity.Layer ?? "";
|
||||
worksheet.Cells[row, 4] = ""; // Tag는 빈 값
|
||||
worksheet.Cells[row, 5] = fileName ?? "";
|
||||
worksheet.Cells[row, 6] = noteEntity.Text ?? "";
|
||||
|
||||
Debug.WriteLine($"[DEBUG] Excel 기록: Row {row}, Order {noteEntity.SortOrder}, Type {noteEntity.Type}, Pos({noteEntity.X:F1},{noteEntity.Y:F1}), Text: '{noteEntity.Text}'");
|
||||
row++;
|
||||
}
|
||||
|
||||
Debug.WriteLine($"[DEBUG] Note 데이터 기록 완료: {row - startRow}개 항목");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[DEBUG] Note 데이터 입력 오류: {ex.Message}");
|
||||
Debug.WriteLine($"[DEBUG] 처리된 행: {row - startRow}개");
|
||||
}
|
||||
|
||||
// AutoFit 시도 (오류 발생시 무시)
|
||||
try
|
||||
{
|
||||
worksheet.Columns.AutoFit();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[DEBUG] AutoFit 오류 (무시됨): {ex.Message}");
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"❌ WriteNoteEntities 전체 오류: {ex.Message}");
|
||||
Debug.WriteLine($" 스택 트레이스: {ex.StackTrace}");
|
||||
throw; // 상위로 예외 전파
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user