[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column is an INT instead of a STRING (column letter) #5

Closed
Hackndo opened this issue Mar 21, 2019 · 0 comments
Closed

Column is an INT instead of a STRING (column letter) #5

Hackndo opened this issue Mar 21, 2019 · 0 comments

Comments

@Hackndo
Copy link
Contributor
Hackndo commented Mar 21, 2019

Hi,

Version

openpyxl==2.6.1

File

bloodhoundanalytics.py

Error

def save_workbook(self):
		for worksheet in self.workbook._sheets:
			for col in worksheet.columns:
				max_length = 0
				column = col[0].column  # Get the column name
				for cell in col:
					try:  # Necessary to avoid error on empty cells
						if len(str(cell.value)) > max_length:
							max_length = len(cell.value)
					except:
						pass
				adjusted_width = (max_length + 2) * 1.2
				worksheet.column_dimensions[column].width = adjusted_width
		self.workbook.save("BloodHoundAnalytics.xlsx")

This line column = col[0].column # Get the column name returns the column number (1, 2, ...) instead of its name.

Recommandation

Use from openpyxl.utils import get_column_letter to get the column's letter

Fix

A pull request was made

rvazarkar added a commit that referenced this issue Apr 3, 2019
Fix #5 Column is an INT instead of a STRING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant