Skip to content

Commit

Permalink
fixed how to display cell width and height in copycat
Browse files Browse the repository at this point in the history
  • Loading branch information
j2doll committed Aug 28, 2019
1 parent 8a4ce35 commit 0a26c17
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
35 changes: 28 additions & 7 deletions Copycat/XlsxTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,13 @@ bool XlsxTab::setSheet()
double dRowHeight = wsheet->rowHeight( cl.row );
double dColWidth = wsheet->columnWidth( cl.col );

qDebug() <<" ROW HEIGHT: " << dRowHeight << " COLUMN WIDTH: " << dColWidth;
// qDebug() <<" ROW HEIGHT: " << dRowHeight << " COLUMN WIDTH: " << dColWidth;

// dRowHeight = dRowHeight * double(2.0);
// dColWidth = dColWidth * double(2.0);
double wWidth = cellWidthToWidgetWidth( dColWidth );
double wHeight = cellHeightToWidgetHeight( dRowHeight );

// TODO: define ratio of widget col/row

// table->setRowHeight( row, dRowHeight );
// table->setColumnWidth( col, dColWidth );
table->setRowHeight( row, wHeight );
table->setColumnWidth( col, wWidth );

////////////////////////////////////////////////////////////////////
// font
Expand Down Expand Up @@ -349,3 +347,26 @@ std::string XlsxTab::convertFromNumberToExcelColumn(int n)
return stdString;
}

// 72 points (DPI) = 1 inch = 2.54 cm = 96 pixels
// 1 PT(point) = 1.333 PX(pixel) (point is a absolute unit.)
// 1 PX(pixel) = 0.75 PT(point) (pixel is a relative unit.) (In Windows. Mac is diffrent.)

double XlsxTab::cellWidthToWidgetWidth(double width)
{
// unit of width is a character. default value is 8.43.
// 8.43 characters = 64 pixel = 48 point (in Windows)

double ret = width * (double(64) / double(8.43));
return ret;
}

double XlsxTab::cellHeightToWidgetHeight(double height)
{
// default value is 16.5 point
// 3 point = 4 pixel

double ret = height * (double(3) / double(4));
return ret;
}


2 changes: 2 additions & 0 deletions Copycat/XlsxTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public slots:
protected:
bool setSheet();
std::string convertFromNumberToExcelColumn(int n);
double cellWidthToWidgetWidth(double width);
double cellHeightToWidgetHeight(double height);

};

Expand Down

0 comments on commit 0a26c17

Please sign in to comment.