개정판 86663325
issue #665: can save
DTI_PID/DTI_PID/ItemDataExportDialog.py | ||
---|---|---|
173 | 173 |
@history 2018.10.26 euisung export order apply |
174 | 174 |
''' |
175 | 175 |
def qtable_to_sheet(self, table, sheet, index): |
176 |
self.set_sheet_header(table, sheet, index) |
|
177 |
self.set_sheet_data(table, sheet, index) |
|
178 |
self.auto_resize_columns(sheet) |
|
176 |
try: |
|
177 |
self.set_sheet_header(table, sheet, index) |
|
178 |
self.set_sheet_data(table, sheet, index) |
|
179 |
self.auto_resize_columns(sheet) |
|
180 |
except Exception as ex: |
|
181 |
from App import App |
|
182 |
from AppDocData import MessageType |
|
183 |
|
|
184 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
185 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
179 | 186 |
|
180 | 187 |
''' |
181 | 188 |
@brief save excel |
... | ... | |
244 | 251 |
@author kyouho |
245 | 252 |
@date 2018.08.16 |
246 | 253 |
""" |
247 |
thin = Side(border_style='thin', color='000000') |
|
248 |
border = Border(left=thin, right=thin, top=thin, bottom=thin) |
|
249 |
logicalCol = [] |
|
250 |
withoutEmpty = [] |
|
251 |
emptys = [] |
|
252 |
for col in range(len(self.columnOrder[index])): |
|
253 |
if self.columnOrder[index][col].split(self.delimiterCombine)[0] == self.emptyCol: |
|
254 |
emptys.append(col) |
|
255 |
else: |
|
256 |
withoutEmpty.append(self.columnOrder[index][col]) |
|
254 |
try: |
|
255 |
thin = Side(border_style='thin', color='000000') |
|
256 |
border = Border(left=thin, right=thin, top=thin, bottom=thin) |
|
257 |
logicalCol = [] |
|
258 |
withoutEmpty = [] |
|
259 |
emptys = [] |
|
260 |
for col in range(len(self.columnOrder[index])): |
|
261 |
if self.columnOrder[index][col].split(self.delimiterCombine)[0] == self.emptyCol: |
|
262 |
emptys.append(col) |
|
263 |
else: |
|
264 |
withoutEmpty.append(self.columnOrder[index][col]) |
|
257 | 265 |
|
258 |
for header in range(len(withoutEmpty)): |
|
259 |
target = withoutEmpty[header].split(self.delimiterCombine)[0] |
|
260 |
for col in range(len(self.columnListAll[index])): |
|
261 |
if target == self.columnListAll[index][col]: |
|
262 |
logicalCol.append(table.horizontalHeader().logicalIndex(col)) |
|
263 |
break |
|
266 |
for header in range(len(withoutEmpty)):
|
|
267 |
target = withoutEmpty[header].split(self.delimiterCombine)[0]
|
|
268 |
for col in range(len(self.columnListAll[index])):
|
|
269 |
if target == self.columnListAll[index][col]:
|
|
270 |
logicalCol.append(table.horizontalHeader().logicalIndex(col))
|
|
271 |
break
|
|
264 | 272 |
|
265 |
for rowIndex in range(table.rowCount()): |
|
266 |
col = 1 |
|
267 |
for header in logicalCol: |
|
268 |
if not header: |
|
273 |
exportCol = [0] |
|
274 |
position = 1 |
|
275 |
for col in range(1, len(self.columnOrder[index])): |
|
276 |
if self.columnOrder[index][col].split(self.delimiterCombine)[0] == self.emptyCol: |
|
277 |
position += 1 |
|
269 | 278 |
continue |
279 |
exportCol.append(position) |
|
280 |
position += 1 |
|
270 | 281 |
|
271 |
widgetItem = table.cellWidget(rowIndex, header) |
|
272 |
if widgetItem is None: |
|
273 |
data = table.item(rowIndex, header).text() if table.item(rowIndex, header) is not None else '' |
|
274 |
else: |
|
275 |
if widgetItem.currentIndex() >= 0: |
|
276 |
data = widgetItem.currentText() |
|
282 |
for rowIndex in range(table.rowCount()): |
|
283 |
for header in range(len(logicalCol)): |
|
284 |
if not logicalCol[header]: |
|
285 |
continue |
|
286 |
|
|
287 |
widgetItem = table.cellWidget(rowIndex, logicalCol[header]) |
|
288 |
if widgetItem is None: |
|
289 |
data = table.item(rowIndex, logicalCol[header]).text() if table.item(rowIndex, logicalCol[header]) is not None else '' |
|
277 | 290 |
else: |
278 |
data = '' |
|
279 |
|
|
280 |
exportCol = col |
|
281 |
for i in range(len(emptys)): |
|
282 |
if col >= emptys[i]: |
|
283 |
exportCol += 1 |
|
284 |
sheet.cell(rowIndex + 2, exportCol, data) |
|
285 |
#sheet.cell(row = rowIndex+2, column = exportCol).border = border |
|
286 |
col += 1 |
|
287 |
for rowIndex in range(table.rowCount()): |
|
288 |
for colIndex in range(1, len(self.columnOrder[index])): |
|
289 |
sheet.cell(row = rowIndex+2, column = colIndex).border = border |
|
291 |
if widgetItem.currentIndex() >= 0: |
|
292 |
data = widgetItem.currentText() |
|
293 |
else: |
|
294 |
data = '' |
|
295 |
|
|
296 |
sheet.cell(rowIndex + 2, exportCol[header], data) |
|
297 |
|
|
298 |
for rowIndex in range(table.rowCount()): |
|
299 |
for colIndex in range(1, len(self.columnOrder[index])): |
|
300 |
sheet.cell(row = rowIndex+2, column = colIndex).border = border |
|
301 |
except Exception as ex: |
|
302 |
from App import App |
|
303 |
from AppDocData import MessageType |
|
304 |
|
|
305 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
306 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
290 | 307 |
|
291 | 308 |
def auto_resize_columns(self, sheet): |
292 | 309 |
""" |
내보내기 Unified diff