#计算边桩坐标 import math sheet_coord = sheet("coord_calc") with sheet_coord: row = 2 while not cell(row, 2).empty(): x = cell(row, 2).value y = cell(row, 3).value a = cell(row, 4).value if not cell(row, 6).empty(): d = cell(row, 6).value if cell(row, 7).empty(): ap = math.pi / 2 else: ap = cell(row, 7).value cell(row, 8).value = x - math.cos(a + ap) * d cell(row, 9).value = y - math.sin(a + ap) * d if not cell(row, 10).empty(): d = cell(row, 10).value if cell(row, 11).empty(): ap = math.pi / 2 else: ap = cell(row, 11).value cell(row, 12).value = x + math.cos(a + ap) * d cell(row, 13).value = y + math.sin(a + ap) * d row += 1 sheet_coord.fit_content()