1
0
Fork 0

fix mac height

master
嘉祥 詹 2024-10-09 19:11:28 +08:00
parent 5f49b51dd1
commit e64e1727b5
1 changed files with 28 additions and 5 deletions

View File

@ -518,6 +518,14 @@ namespace QuotationMaker.Controllers
saRowIndex--;
}
string agent = Request.Headers["User-Agent"].ToString();
string post_pc = "win";
if (agent.Contains("Macintosh"))
{
post_pc = "mac";
}
//自适应高度9代表从第10行开始表头部分不会多行endRow是结束的行也就是有数据内容的行数毕竟没内容的单元格也没必要自适应行高
for (int i = saRowIndex; i < saRowIndex + 3; i++)
@ -543,7 +551,7 @@ namespace QuotationMaker.Controllers
cellWidth += sheet.GetColumnWidth(k);
}
int cellStringLength = GetCellStringLength(CurCell.StringCellValue);
int cellStringLength = GetCellStringLength(CurCell.StringCellValue, post_pc);
if (cellStringLength > cellWidth) {
double newHg1 = (double)(OldHg * (cellStringLength / cellWidth + 1));
@ -624,7 +632,7 @@ namespace QuotationMaker.Controllers
string downloadName = objDetail.quotation_name + " 報價單_" + DateTime.Now.ToString("yyyy-MM-dd");
string agent = Request.Headers["User-Agent"].ToString();
//if (agent.Contains("Macintosh"))
//{
@ -647,7 +655,7 @@ namespace QuotationMaker.Controllers
/// </summary>
/// <param name="text">待判断字符或字符串</param>
/// <returns>宽度</returns>
public int GetCellStringLength(string text)
public int GetCellStringLength(string text, string pc_type)
{
//汉字 453、数字和字母 239
//这里的汉字与字母的宽度值要根据Excel的字体大小计算
@ -663,11 +671,26 @@ namespace QuotationMaker.Controllers
}
else if (t > 127)
{
result += 660;
if (pc_type == "win")
{
result += 660;
}
else {
result += 760;
}
}
else
{
result += 370;
if (pc_type == "win")
{
result += 370;
}
else {
result += 440;
}
}
}
return result;