프로젝트

일반

사용자정보

개정판 4d8aefe7

ID4d8aefe74c6b0330c4103c88fa6a15d86cd2f6dd
상위 5b3801e5
하위 5ace22e9, d469ad24

임예철이(가) 약 4년 전에 추가함

issue #1059: Upload ReportApp (예외처리 추가)

Change-Id: Ibaf38d873ff7b28d956b7e33a31a7e4c9c02c70e

차이점 보기:

HYTOS/HYTOS/MainWindow.py
1559 1559
                self.showImageSelectionMessageBox()
1560 1560
                return
1561 1561

  
1562
            image_path = None
1562
            svg_path = None
1563 1563
            with NamedTemporaryFile() as f:
1564
                image_path = f.name + '.png'
1564
                svg_path = f.name + '.svg'
1565 1565

  
1566
            if image_path:
1566
            if svg_path:
1567 1567
                self.on_view_connector(False)  # hide connector
1568
                self.graphicsView.save_as_image(image_path)  # try to use save_as_svg when will generate svg file
1568
                self.graphicsView.save_as_svg(svg_path)  # try to use save_as_svg when will generate svg file
1569 1569

  
1570 1570
                workspace = self.get_work_space()
1571 1571
                file_name = os.path.join(workspace, app_doc_data.activeDrawing.name + '.xlsx')
......
1594 1594
                    for page in range(pages):
1595 1595
                        ws = wb.copy_worksheet(wb.get_sheet_by_name('Page'))
1596 1596
                        ws.title = f"Page ({page_no})"
1597

  
1597
                        """
1598 1598
                        cal_image = openpyxl.drawing.image.Image(image_path)  # TODO: try to insert svg file instead of image
1599 1599
                        x_scale = MainWindow.PAPER_SIZE.width() / cal_image.width
1600 1600
                        y_scale = MainWindow.PAPER_SIZE.height() / cal_image.height
1601 1601
                        cal_image.width *= x_scale
1602 1602
                        cal_image.height *= y_scale
1603 1603
                        ws.add_image(cal_image, 'A1')
1604

  
1604
                        """
1605 1605
                        company_image = openpyxl.drawing.image.Image(company_image_path)
1606 1606
                        company_image.width *= 0.8
1607 1607
                        company_image.height *= 0.7
......
2208 2208
                    save_file_name = file_name if ext.upper() == '.XLSX' else name_without_ext + '.xlsx'
2209 2209
                    wb.save(filename=save_file_name)
2210 2210

  
2211
                    os.startfile(save_file_name)
2211
                    input_svg_exe_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ReportApp',
2212
                                                      'ReportApp.exe')
2213
                    blank_save_file_name = f'"{save_file_name}"'  # Error : File or Directory used Black
2214

  
2215
                    svg_input_result = os.system(f"{input_svg_exe_path} {blank_save_file_name} {svg_path}")
2212 2216

  
2213
                    QMessageBox.information(self, self.tr('Information'), self.tr('Report is done'))
2217
                    if svg_input_result == 1:
2218
                        os.startfile(save_file_name)
2219
                        # QMessageBox.information(self, self.tr('Information'), self.tr('Report is done'))
2220
                    elif svg_input_result == 0:
2221
                        QMessageBox.information(self, self.tr('Information'),
2222
                                                self.tr('Could not find excel file or svg file'))
2214 2223
        except Exception as ex:
2215 2224
            message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
2216 2225
                      f"{sys.exc_info()[-1].tb_lineno}"
ReportApp/ReportApp/Program.cs
9 9
{
10 10
    class Program
11 11
    {
12
        static void Main(string[] args)
12
        static int Main(string[] args)
13 13
        {
14 14
            SpreadsheetInfo.SetLicense("SN-2021May25-IPYYaC5T2J/LIzFImndeajkkMS/Fn1fLWGfjRRxTNu/uan2hm9KrTK/v9hdsQfLCOuUeMZXrEHCPsmS7Pnp4YGIGsOw==A");
15
            //string[] arg = new string[] { "D:/Projects/HYTOS/Docs/P-9203_20210427.xlsx", "C:\\Users\\shj\\AppData\\Local\\Temp\\tmpc35x0f14.svg"};
16
            string Execl_Path = args[0];
17
            string Svg_Path = args[1].Replace("\\", "/");
18 15

  
19
            var workbook = ExcelFile.Load(Execl_Path);
20

  
21
            foreach (var worksheet in workbook.Worksheets)
16
            if (args[0] != null && args[1] != null && args.Count() == 2)
22 17
            {
23
                worksheet.Pictures.Add(Svg_Path, "A1", 1500, 990, LengthUnit.Pixel);
24
            }
25
            workbook.Save(Execl_Path);
18
                string ExeclPath = args[0];
19
                string SvgPath = args[1].Replace("\\", "/");
26 20

  
21
                var workbook = ExcelFile.Load(ExeclPath);
22

  
23
                foreach (var worksheet in workbook.Worksheets)
24
                {
25
                    worksheet.Pictures.Add(SvgPath, "A1", 1500, 990, LengthUnit.Pixel);
26
                }
27
                workbook.Save(ExeclPath);
28
                return 1;
29
            }
30
            return 0;           
27 31
        }
28 32
    }
29 33
}
ReportApp/ReportApp/ReportApp.csproj
43 43
      <HintPath>..\packages\BouncyCastle.1.8.9\lib\BouncyCastle.Crypto.dll</HintPath>
44 44
    </Reference>
45 45
    <Reference Include="GemBox.Spreadsheet, Version=47.0.0.1207, Culture=neutral, PublicKeyToken=b1b72c69714d4847, processorArchitecture=MSIL">
46
      <HintPath>..\packages\GemBox.Spreadsheet.47.0.1207\lib\net35\GemBox.Spreadsheet.dll</HintPath>
46
      <SpecificVersion>False</SpecificVersion>
47
      <HintPath>..\packages\GemBox.Spreadsheet.47\net35\GemBox.Spreadsheet.dll</HintPath>
47 48
    </Reference>
48 49
    <Reference Include="PresentationCore" />
49 50
    <Reference Include="PresentationFramework" />

내보내기 Unified diff

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