728x90

요즘에 QXlsx를 이용해서 프로그램의 실행 결과를 자동으로 엑셀로 만들어주는 기능을 작업하고 있습니다.

 

이때 Summary 시트의 결과 셀을 누르면 Log 시트의 특정 Cell로 이동하게 만들고 싶어서 Hyperlink 코드 추가했습니다.

Url을 "#시트이름!셀"로 넣고 마지막 "text" 부분에 실제 표시할 텍스트를 넣어주시면 됩니다.

#include <xlsxdocument.h>
#include <xlsxworksheet.h>

{
    ...;
    
    auto currentSheet = reportFile.currentWorksheet();
    
    QXlsx::Format linkFormat;
    linkFormat.setFontColor(Qt::blue);
    linkFormat.setFontUnderline(QXlsx::Format::FontUnderlineSingle);
    
    QString sLogCellUrl = QString("#%1!A%2").arg("Log", QString::number(Row));
    currentSheet->writeHyperlink(nRow, nColumn++, QUrl(sLogCellUrl), linkFormat, "text");
    ...;
    
}

 

728x90

+ Recent posts

Buy Me A Coffee