我有一个Excel 2016 Book.xlsm
。在工作表testsheet
中,A1:Y150
范围内的单元格中填充了文本或数字内容。左上角的单元格始终为A1
。
我正在使用python v3 xlwings打开Excel文件。
import xlwings as xw
Book_name = 'C:/Users/name/Book.xlsm'
sheet_name = 'testsheet'
wb = xw.Book(Book_name)
sht = wb.sheets[sheet_name]
如何找到使用python填充内容的单元格范围,在本例中为A1:Y150
?
答案 0 :(得分:1)
如果print (wb.sheets[sheet_name].api.UsedRange.Address)
被定义为Excel工作簿,那么这是一个好方法:
if (response.data[0].projectionType == "LTLRate") {
scf.ConfirmTenderLTLRates(scf.confirmTenderLTLTenderId, scf.SelectedOrderDetails.TLOrderId);
}
scf.ConfirmTenderLTLRates = function (TenderId, TLOrderId) {
$("#imgLoading").show(); //Am TRYING to keep the loader running, but fails
if (TenderId > 0) {
var requestData = {
Id: TenderId,
shipmentId: TLOrderId,
PROWithTenderConfirm: scf.PROWithTenderConfirm
};
ShipmentService.confirmTender(requestData).then(function (response) {
$("#imgLoading").show();
if (response.data.Id != null)
if (response.data.Id > 0) {
scf.SelectedOrderDetails.FreightCharges = parseFloat(response.data.markupTotal).toFixed(2);
}
$('#ShipmentTenderingGrid').data('kendoGrid').dataSource.read();
SweetAlert.swal("Tender Confirmed Successfully!", "", "success");
scf.editShipment(TLOrderId, 1);
});
}
}
答案 1 :(得分:0)
您可以使用used_range填充内容:
import xlwings as xw
filename = "test.xlsx"
wb = xw.Book(filename)
ws = wb.sheets["SheetX"]
a_range = ws.used_range.address
print(a_range)