프로젝트

일반

사용자정보

개정판 aa73d664

IDaa73d664a90a8d05d1156384ca3015a33be40cf8
상위 57ae0756
하위 b5f9f7fb

이지연이(가) 9달 전에 추가함

issue #000: gembox 추가

Change-Id: Id37f615a3b5f0d9ac8f07b1c48effa1c718de2cf

차이점 보기:

KCOM/Controls/CheckList.xaml.cs
21 21
using KCOM.Controls;
22 22
using KCOM.Common;
23 23
using IKCOM;
24
using Excel = Microsoft.Office.Interop.Excel;
25 24
using System.Text.RegularExpressions;
25
using GemBox.Spreadsheet;
26
using System.IO;
26 27

  
27 28
namespace KCOM.Controls
28 29
{
......
384 385

  
385 386
        #region Excel Export
386 387

  
388
        [Obsolete]
387 389
        private void ExportEvent(object sender, RoutedEventArgs e)
388 390
        {
389 391
            try
......
418 420
                    using (var client = new System.Net.WebClient())
419 421
                    {
420 422
                        client.DownloadFile(url, dialog.FileName);
421

  
422
                        Excel.Application application = null;
423
                        Excel.Workbook workbook = null;
424
                        Excel.Worksheet worksheet = null;
425

  
423
                        SpreadsheetInfo.SetLicense(Properties.Settings.Default.GemBoxLicense);// "EXK0-W4HZ-N518-IMEW");                    
424
                        ExcelFile workbook = null;
425
                        ExcelWorksheet worksheet = null;
426 426
                        try
427 427
                        {
428
                            // Excel 첫번째 워크시트 가져오기                
429
                            application = new Excel.Application();
430
                            workbook = application.Workbooks.Open(dialog.FileName);
431
                            worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item("Sheet1");
428
                            // Excel 첫번째 워크시트 가져오기             
429
                            workbook = ExcelFile.Load(dialog.FileName);
430
                            worksheet = workbook.Worksheets[0];
432 431

  
433 432
                            // 데이타 넣기
434
                            int h = 9;
435
                            int w = 2;
433
                            int h = 8;
434
                            int w = 1;
436 435
                            string project_no = App.ViewInfo.ProjectNO;
437
                            worksheet.Cells[2, w + 8] = project_no;
438
                            //Logger.sendReqLog("GetProjectName: ", project_no, 1);
436
                            worksheet.Cells[1, w + 8].Value = project_no;
439 437

  
440 438
                            string project_name = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetProjectName(project_no);
441 439
                            if (project_name != null || project_name != "")
......
446 444
                            {
447 445
                                //Logger.sendResLog("GetProjectName", "FALSE", 1);
448 446
                            }
449
                            worksheet.Cells[3, w + 8] = project_name;
447
                            worksheet.Cells[2, w + 8].Value = project_name;
448
                            worksheet.Cells[3, w + 8].Value = (mainWindow as MainWindow).dzMainMenu._DocItem.DOCUMENT_NO;
449
                            worksheet.Cells[4, w + 8].Value = (mainWindow as MainWindow).dzMainMenu.userData.NAME + " (" + App.ViewInfo.UserID + ")";
450
                            worksheet.Cells[5, w + 8].Value = DateTime.Now.ToString("yyyy.MM.dd");
450 451

  
451
                            worksheet.Cells[4, w + 8] = (mainWindow as MainWindow).dzMainMenu._DocItem.DOCUMENT_NO;
452
                            worksheet.Cells[5, w + 8] = (mainWindow as MainWindow).dzMainMenu.userData.NAME + " (" + App.ViewInfo.UserID + ")";
453
                            worksheet.Cells[6, w + 8] = DateTime.Now.ToString("yyyy.MM.dd");
454

  
455
                            Excel.Range Range_I = worksheet.Range["K9"];
456
                            Excel.Range Range_O = null;
457
                            Excel.Borders border_ = null;
452
                            ExcelCell Range_I = worksheet.Cells["K9"];                           
458 453

  
459 454
                            var Rev = Lists.Select(info => info.REVISION).Distinct();
460 455
                            string[] Cell = { "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T" };
461 456
                            string[] Range = { "L9", "M9", "N9", "O9", "P9", "Q9", "R9", "S9", "T9", "U9", "V9", "W9", "X9", "Y9", "Z9", "AA9", "AB9", "AC9", "AD9" };
462 457
                            string Ran = "K";
463 458

  
464
                            for (int i = 0; i < rev_cnt - 1; i++)
465
                            {
466
                                worksheet.Cells[9, 12 + i] = Cell[i];
467
                                Range_O = worksheet.Range[Range[i]];
468
                                border_ = Range_O.Borders;
469
                                border_.LineStyle = Range_I.Borders.LineStyle;
470
                                border_.Weight = Range_I.Borders.Weight;
471
                                Range_O.Interior.Color = Range_I.Interior.Color;
472
                            }
473

  
474
                            worksheet.Range[worksheet.Cells[8, 11], worksheet.Cells[8, 11 + rev_cnt - 1]].Merge();
459
                            worksheet.Cells.GetSubrangeAbsolute(8, 11, 8, 11 + rev_cnt - 1).Merged = true;                       
475 460

  
476 461
                            if (rev_cnt != 1)
477 462
                            {
478 463
                                Ran = Range[rev_cnt - 2].Substring(0, Range[rev_cnt - 2].Length - 1);
479 464
                            }
480
                            Excel.Range iRange = worksheet.Range["B10:" + Ran + "10"];
481

  
465
                            CellRange iRange = worksheet.Cells.GetSubrange("B10:" + Ran + "10");
466
                            
482 467
                            //필터 기능 추가
483
                            Excel.Range Filter_Range = worksheet.Range["B9:" + Ran + "9"];
484
                            Filter_Range.AutoFilter(1, Type.Missing, Excel.XlAutoFilterOperator.xlAnd, Type.Missing, true);
485

  
468
                            CellRange Filter_Range = worksheet.Cells.GetSubrange("B9:" + Ran + "9");
469
                            Filter_Range.Filter(true);
470
                            ExcelCell Range_b = worksheet.Cells["B10"];
486 471
                            Lists.ForEach(data =>
487 472
                            {
488 473
                                h++;
489

  
490
                                Excel.Range oRange = worksheet.Range["B" + h + ":" + Ran + h];
491
                                oRange.RowHeight = iRange.RowHeight;
492
                                Excel.Borders border = oRange.Borders;
493
                                border.LineStyle = Excel.XlLineStyle.xlContinuous;
494
                                border.Weight = 2d;
474
                                // Get the range.
475
                                CellRange oRange = worksheet.Cells.GetSubrange("B" + (h + 1) + ":" + Ran + (h + 1));
476
                                foreach (var cell in oRange)
477
                                {
478
                                    cell.Style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin);
479
                                }
495 480

  
496 481
                                if (data.IMAGE_PATH != null)
497 482
                                {
498
                                    Excel.Range ImageRange = worksheet.Cells[h, w + 2];
499

  
483
                                    ExcelCell ImageRange = worksheet.Cells[h, w + 2];        
484
                                    ImageRange.Row.Height = Range_b.Row.Height;
485
                                    //ImageRange.Style.Font.Size = 10;
500 486
                                    System.Drawing.Image I_Image = byteArrayToImage(data.IMAGE_PATH);
501 487
                                    System.Drawing.Image o_Image = Resize(I_Image, 80, 80);
502 488
                                    System.Windows.Forms.Clipboard.SetDataObject(o_Image, true);
503

  
504
                                    ImageRange.Cells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenterAcrossSelection;
505
                                    ImageRange.Cells.VerticalAlignment = Excel.XlHAlign.xlHAlignCenter;
506

  
507
                                    worksheet.Paste(ImageRange.Cells, "TEST");
508

  
509
                                    foreach (Microsoft.Office.Interop.Excel.Shape shp in worksheet.Shapes)
510
                                    {
511
                                        if (shp.TopLeftCell.Address != ImageRange.Address)
512
                                            continue;
513

  
514
                                        double Left = shp.TopLeftCell.Left + (shp.TopLeftCell.Width - shp.Width) / 2;
515
                                        double Top = shp.TopLeftCell.Top + (shp.TopLeftCell.Height - shp.Height) / 2;
516

  
517
                                        shp.Left = float.Parse(Left.ToString());
518
                                        shp.Top = float.Parse(Top.ToString());
519

  
520
                                        break;
521
                                    }
489
                                    ImageRange.Style.HorizontalAlignment = HorizontalAlignmentStyle.Left;
490
                                    ImageRange.Style.VerticalAlignment = VerticalAlignmentStyle.Top;                                      
491
                                    byte[] imageData = data.IMAGE_PATH;
492
                                    MemoryStream memoryStream = new MemoryStream();
493
                                    o_Image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);                                    
494
                                    int column = 2; // 이미지를 삽입할 열
495
                                    int row = h;    // 이미지를 삽입할 행
496
                                    // 이미지를 워크시트에 추가
497
                                    ExcelPicture picture = worksheet.Pictures.Add(memoryStream, PositioningMode.FreeFloating, new AnchorCell(ImageRange.Column, ImageRange.Row, 0, 0), ExcelPictureFormat.Jpeg);
498

  
499
                                    //foreach (Microsoft.Office.Interop.Excel.Shape shp in worksheet.Shapes)
500
                                    //{
501
                                    //    if (shp.TopLeftCell.Address != ImageRange.Address)
502
                                    //        continue;
503

  
504
                                    //    double Left = shp.TopLeftCell.Left + (shp.TopLeftCell.Width - shp.Width) / 2;
505
                                    //    double Top = shp.TopLeftCell.Top + (shp.TopLeftCell.Height - shp.Height) / 2;
506

  
507
                                    //    shp.Left = float.Parse(Left.ToString());
508
                                    //    shp.Top = float.Parse(Top.ToString());
509

  
510
                                    //    break;
511
                                    //}
522 512
                                }
523 513

  
524 514
                                #region Excel Bind
525
                                worksheet.Cells[h, w] = data.REVISION;
526
                                worksheet.Cells[h, w + 1] = data.PAGENUMBER;
527
                                worksheet.Cells[h, w + 3] = data.TODOLIST;
528
                                worksheet.Cells[h, w + 4] = data.STATUS.ToUpper() == "TRUE" ? "closed" : "open";
529
                                worksheet.Cells[h, w + 5] = data.STATUS_DESC;
530
                                worksheet.Cells[h, w + 6] = data.VENDOR;
531
                                worksheet.Cells[h, w + 7] = data.REMARK;
532
                                worksheet.Cells[h, w + 8] = data.REPLY;
533
                                worksheet.Cells[h, w + 9] = data.REV_0 == null ? "" : data.REV_0.Replace("", " / ");
534
                                worksheet.Cells[h, w + 10] = data.REV_1 == null ? "" : data.REV_1.Replace("", " / ");
535
                                worksheet.Cells[h, w + 11] = data.REV_2 == null ? "" : data.REV_2.Replace("", " / ");
536
                                worksheet.Cells[h, w + 12] = data.REV_3 == null ? "" : data.REV_3.Replace("", " / ");
537
                                worksheet.Cells[h, w + 13] = data.REV_4 == null ? "" : data.REV_4.Replace("", " / ");
538
                                worksheet.Cells[h, w + 14] = data.REV_5 == null ? "" : data.REV_5.Replace("", " / ");
539
                                worksheet.Cells[h, w + 15] = data.REV_6 == null ? "" : data.REV_6.Replace("", " / ");
540
                                worksheet.Cells[h, w + 16] = data.REV_7 == null ? "" : data.REV_7.Replace("", " / ");
541
                                worksheet.Cells[h, w + 17] = data.REV_8 == null ? "" : data.REV_8.Replace("", " / ");
542
                                worksheet.Cells[h, w + 18] = data.REV_9 == null ? "" : data.REV_9.Replace("", " / ");
543
                                worksheet.Cells[h, w + 19] = data.REV_10 == null ? "" : data.REV_10.Replace("", " / ");
544
                                worksheet.Cells[h, w + 20] = data.REV_11 == null ? "" : data.REV_11.Replace("", " / ");
545
                                worksheet.Cells[h, w + 21] = data.REV_12 == null ? "" : data.REV_12.Replace("", " / ");
546
                                worksheet.Cells[h, w + 22] = data.REV_13 == null ? "" : data.REV_13.Replace("", " / ");
547
                                worksheet.Cells[h, w + 23] = data.REV_14 == null ? "" : data.REV_14.Replace("", " / ");
548
                                worksheet.Cells[h, w + 24] = data.REV_15 == null ? "" : data.REV_15.Replace("", " / ");
549
                                worksheet.Cells[h, w + 25] = data.REV_16 == null ? "" : data.REV_16.Replace("", " / ");
550
                                worksheet.Cells[h, w + 26] = data.REV_17 == null ? "" : data.REV_17.Replace("", " / ");
551
                                worksheet.Cells[h, w + 27] = data.REV_18 == null ? "" : data.REV_18.Replace("", " / ");
552
                                worksheet.Cells[h, w + 28] = data.REV_19 == null ? "" : data.REV_19.Replace("", " / ");
515
                                worksheet.Cells[h, w].Value = data.REVISION;
516
                                worksheet.Cells[h, w + 1].Value = data.PAGENUMBER;
517
                                worksheet.Cells[h, w + 3].Value = data.TODOLIST;
518
                                worksheet.Cells[h, w + 4].Value = data.STATUS.ToUpper() == "TRUE" ? "closed" : "open";
519
                                worksheet.Cells[h, w + 5].Value = data.STATUS_DESC;
520
                                worksheet.Cells[h, w + 6].Value = data.VENDOR;
521
                                worksheet.Cells[h, w + 7].Value = data.REMARK;
522
                                worksheet.Cells[h, w + 8].Value = data.REPLY;
523
                                worksheet.Cells[h, w + 9].Value = data.REV_0 == null ? "" : data.REV_0.Replace("", " / ");
524
                                worksheet.Cells[h, w + 10].Value = data.REV_1 == null ? "" : data.REV_1.Replace("", " / ");
525
                                worksheet.Cells[h, w + 11].Value = data.REV_2 == null ? "" : data.REV_2.Replace("", " / ");
526
                                worksheet.Cells[h, w + 12].Value = data.REV_3 == null ? "" : data.REV_3.Replace("", " / ");
527
                                worksheet.Cells[h, w + 13].Value = data.REV_4 == null ? "" : data.REV_4.Replace("", " / ");
528
                                worksheet.Cells[h, w + 14].Value = data.REV_5 == null ? "" : data.REV_5.Replace("", " / ");
529
                                worksheet.Cells[h, w + 15].Value = data.REV_6 == null ? "" : data.REV_6.Replace("", " / ");
530
                                worksheet.Cells[h, w + 16].Value = data.REV_7 == null ? "" : data.REV_7.Replace("", " / ");
531
                                worksheet.Cells[h, w + 17].Value = data.REV_8 == null ? "" : data.REV_8.Replace("", " / ");
532
                                worksheet.Cells[h, w + 18].Value = data.REV_9 == null ? "" : data.REV_9.Replace("", " / ");
533
                                worksheet.Cells[h, w + 19].Value = data.REV_10 == null ? "" : data.REV_10.Replace("", " / ");
534
                                worksheet.Cells[h, w + 20].Value = data.REV_11 == null ? "" : data.REV_11.Replace("", " / ");
535
                                worksheet.Cells[h, w + 21].Value = data.REV_12 == null ? "" : data.REV_12.Replace("", " / ");
536
                                worksheet.Cells[h, w + 22].Value = data.REV_13 == null ? "" : data.REV_13.Replace("", " / ");
537
                                worksheet.Cells[h, w + 23].Value = data.REV_14 == null ? "" : data.REV_14.Replace("", " / ");
538
                                worksheet.Cells[h, w + 24].Value = data.REV_15 == null ? "" : data.REV_15.Replace("", " / ");
539
                                worksheet.Cells[h, w + 25].Value = data.REV_16 == null ? "" : data.REV_16.Replace("", " / ");
540
                                worksheet.Cells[h, w + 26].Value = data.REV_17 == null ? "" : data.REV_17.Replace("", " / ");
541
                                worksheet.Cells[h, w + 27].Value = data.REV_18 == null ? "" : data.REV_18.Replace("", " / ");
542
                                worksheet.Cells[h, w + 28].Value = data.REV_19 == null ? "" : data.REV_19.Replace("", " / ");
553 543
                                #endregion
554 544
                            });
545
                                                     
546
                            for (int columnIndex = 1; columnIndex < 11; ++columnIndex)
547
                            {    
548
                                worksheet.Columns[columnIndex].AutoFit();
549
                            }
555 550

  
556
                            worksheet.Columns.AutoFit();
551
                            worksheet.Columns["G"].Width = Convert.ToInt32(worksheet.Columns["G"].Width * 1.1);
557 552
                            // 엑셀파일 저장
558
                            workbook.Save();
559
                            workbook.Close(true);
560
                            application.Quit();
553
                            workbook.Save(dialog.FileName);
554
                           
561 555
                        }
562 556
                        finally
563
                        {
564
                            System.Diagnostics.Process[] ExCel = System.Diagnostics.Process.GetProcessesByName("EXCEL");
565
                            if (ExCel.Count() != 0)
566
                            {
567
                                ExCel[0].Kill();
568
                            }
569

  
557
                        {                        
570 558
                            // Clean up
571 559
                            ReleaseExcelObject(worksheet);
572 560
                            ReleaseExcelObject(workbook);
573
                            ReleaseExcelObject(application);
574 561
                        }
575 562
                    }
576 563
                    DialogMessage_Alert("Success");
......
585 572

  
586 573
        }
587 574

  
575
        private static void SetWidth(ExcelColumn column, double width)
576
        {
577
            column.SetWidth(
578
                Math.Truncate((width * 7 + 5) / 7 * 256) / 256,
579
                LengthUnit.ZeroCharacterWidth);
580
        }
581

  
582

  
588 583
        public System.Drawing.Image byteArrayToImage(byte[] byteArrayIn)
589 584
        {
590 585
            using (var ms = new System.IO.MemoryStream(byteArrayIn))
KCOM/Controls/PrintControl.xaml.cs
19 19
//using Leadtools.Windows.Controls;
20 20
using IKCOM;
21 21
using iTextSharp.text.pdf;
22
using Microsoft.Office.Core;
23 22
using System.Net;
24 23
using Image = System.Windows.Controls.Image;
25 24

  
KCOM/KCOM.csproj
484 484
    <Reference Include="ConfigParser, Version=0.3.4.3, Culture=neutral, processorArchitecture=MSIL">
485 485
      <HintPath>..\packages\Salaros.ConfigParser.0.3.4\lib\net45\ConfigParser.dll</HintPath>
486 486
    </Reference>
487
    <Reference Include="GemBox.Spreadsheet, Version=39.3.30.1215, Culture=neutral, PublicKeyToken=b1b72c69714d4847, processorArchitecture=MSIL">
488
      <HintPath>..\packages\GemBox.Spreadsheet.39.3.30.1215\lib\net30\GemBox.Spreadsheet.dll</HintPath>
489
    </Reference>
487 490
    <Reference Include="itextsharp">
488 491
      <HintPath>..\packages\iTextSharp.5.5.12\lib\itextsharp.dll</HintPath>
489 492
    </Reference>
490
    <Reference Include="log4net, Version=2.0.17.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
491
      <HintPath>..\packages\log4net.2.0.17\lib\net45\log4net.dll</HintPath>
493
    <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
494
      <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
492 495
    </Reference>
493 496
    <Reference Include="Microsoft.AspNet.SignalR.Client">
494 497
      <HintPath>..\packages\Microsoft.AspNet.SignalR.Client.2.2.3\lib\net40\Microsoft.AspNet.SignalR.Client.dll</HintPath>
......
1172 1175
    <Resource Include="Resources\Images\OCSStatusImage\IMNUNK.PNG" />
1173 1176
  </ItemGroup>
1174 1177
  <ItemGroup>
1175
    <COMReference Include="Microsoft.Office.Core">
1176
      <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
1177
      <VersionMajor>2</VersionMajor>
1178
      <VersionMinor>8</VersionMinor>
1179
      <Lcid>0</Lcid>
1180
      <WrapperTool>primary</WrapperTool>
1181
      <Isolated>False</Isolated>
1182
      <EmbedInteropTypes>True</EmbedInteropTypes>
1183
    </COMReference>
1184
    <COMReference Include="Microsoft.Office.Interop.Excel">
1185
      <Guid>{00020813-0000-0000-C000-000000000046}</Guid>
1186
      <VersionMajor>1</VersionMajor>
1187
      <VersionMinor>9</VersionMinor>
1188
      <Lcid>0</Lcid>
1189
      <WrapperTool>primary</WrapperTool>
1190
      <Isolated>False</Isolated>
1191
      <EmbedInteropTypes>True</EmbedInteropTypes>
1192
    </COMReference>
1193
  </ItemGroup>
1194
  <ItemGroup>
1195 1178
    <Resource Include="Resources\Images\MenuImage_New\arc.png" />
1196 1179
    <Resource Include="Resources\Images\MenuImage_New\arrow.png" />
1197 1180
    <Resource Include="Resources\Images\MenuImage_New\arrowText.png" />
KCOM/Properties/Settings.Designer.cs
273 273
                this["FontFamily"] = value;
274 274
            }
275 275
        }
276
        
277
        [global::System.Configuration.UserScopedSettingAttribute()]
278
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
279
        [global::System.Configuration.DefaultSettingValueAttribute("EXK0-W4HZ-N518-IMEW")]
280
        public string GemBoxLicense {
281
            get {
282
                return ((string)(this["GemBoxLicense"]));
283
            }
284
            set {
285
                this["GemBoxLicense"] = value;
286
            }
287
        }
276 288
    }
277 289
}
KCOM/Properties/Settings.settings
71 71
    <Setting Name="FontFamily" Type="System.String" Scope="User">
72 72
      <Value Profile="(Default)" />
73 73
    </Setting>
74
    <Setting Name="GemBoxLicense" Type="System.String" Scope="User">
75
      <Value Profile="(Default)">EXK0-W4HZ-N518-IMEW</Value>
76
    </Setting>
74 77
  </Settings>
75 78
</SettingsFile>
KCOM/app.config
96 96
      <setting name="FontFamily" serializeAs="String">
97 97
        <value />
98 98
      </setting>
99
      <setting name="GemBoxLicense" serializeAs="String">
100
        <value>EXK0-W4HZ-N518-IMEW</value>
101
      </setting>
99 102
    </KCOM.Properties.Settings>
100 103
  </userSettings>
101 104
  <system.serviceModel>
KCOM/packages.config
2 2
<packages>
3 3
  <package id="Bytescout.PDFExtractor" version="9.0.0.3095" targetFramework="net461" />
4 4
  <package id="EntityFramework" version="6.2.0" targetFramework="net45" />
5
  <package id="GemBox.Spreadsheet" version="39.3.30.1215" targetFramework="net461" />
5 6
  <package id="ICSharpCode.SharpZipLib.dll" version="0.85.4.369" targetFramework="net40" />
6
  <package id="log4net" version="2.0.17" targetFramework="net461" />
7
  <package id="log4net" version="2.0.8" targetFramework="net45" />
7 8
  <package id="Microsoft.CSharp" version="4.5.0" targetFramework="net461" />
8 9
  <package id="Microsoft.Net.Compilers" version="4.2.0" targetFramework="net461" developmentDependency="true" />
9 10
  <package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1000" targetFramework="net40" />

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)