Closed laurentcabot closed 4 years ago
... perhaps with Excel line grouping. There is a relation class in the ReqIf described in the ReqIf Standard.
well .. the hierarchy is in the python data model, only the excel-exporter does not make use of it. If you look at example.py, an ascii export is done which respects the hierarchy.
Hum... I'm going to have a look. I know: rebuilding the hierarchy in Excel is not so obvious. Anyway, thanks for feedback.
I'm gonna look if i find some idea for excel
Please try branch iss9:
pip install git+https://github.com/ebroecker/pyreqif@iss9
Thanks
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2219' in position 0: ordinal not in range(128)
in xlsx.py line 34.....
@laurentcabot
could you try again?
The ReqIf to Excel works fine now, with respect to the hierarchy. Good job! A nice feature also would be to keep the pictures / attachments that are included in the ReqIf file.
I did some investigation, but did not manage yet to write OLE-Objects in excel with xlsxwriter or openpyxl yet.
So the original issue can be closed now?
Yes, you can close it. Thanks a lot!
well - added some image support also
Checking....
The result is globally correct (only the cell high which is not ajusted to the image). However there is one concern in case of multiple images in the same requirement: only the first one is present. Regarding the cells format (in general), should be top alignment with automatic wrap lines (that's a minor issue!)
@laurentcabot I fixed some of your wishes. Not sure if multiple images work, because the lack of such an input document.
Thanks a lot ! I will try this on monday. I can prepare some ReqIf test files if you need (we use ReqIf Studio)
Thanks a lot ! I will try this on monday. I can prepare some ReqIf test files if you need (we use ReqIf Studio)
Crashes:
write_excel_line C:\HZK1ZQ\JOB\DEV\SW\ReqIf_to_XlsxHtml\pyreqif\xlsx.py 47
TypeError: 'NoneType' object is not callable
OK, I wrote some workaround: https://github.com/ebroecker/pyreqif/commit/a1dc80cb3a24c37340ef05bc9ce576213d534ae4
just try branch iss9 again
generates "Error with image: xxxx" in xlsx.py. I've modified as follows:
try:
im = Image.open(file)
_, height = im.size
max_height = max(height, max_height)
worksheet.set_row(row, max_height, None, {'level': depth})
im.close()
except:
print("Error with image: {}".format(file))
Still hangup with im.close() but generates a xlsx file with correct cells sizes.
Edit: enabled python syntax highlighting
Several images in the same article are still superimposed
Do you get Error with image ..
outputs?
Is so, are these the images, where the height is not correct?
Sorry, did not read your first post.... I guess the Image.open cannot handle your images, what format do they have?
maybe try:
try:
im = Image.open(file)
im.close()
_, height = im.size
max_height = max(height, max_height)
worksheet.set_row(row, max_height, None, {'level': depth})
except:
print("Error with image: {}".format(file))
worksheet.set_row(row, 300, None, {'level': depth})
max_height = max(max_height, 300)
to set row height to 300 if no height could be extracted from image
images are correctly opened (they are png). in step by step mode, the script hangs up at the im.close() OK. I try your patch
same error message, but does not crash. the Excel file is correct except for superimposed messages
The PB is clearly at the "im.close()"
ok, maybe the im.close is wrong anyway. Do you see a height?
does this happen, if there are multiple pictures in one row?
The close won't be necessary, but the height would be good for not superimposed images.
Maybe you could create a minimal example with superimposed images for testing at my side...
Yes the heigh is correct. It happens in any case (single or multiple image) Yes I'm going to create a sample file.
Here it is: Test3.zip The file is downloadable from ReqIf Academy. I've added a multiple image item at the beginning.
With the patch above - Test3 seems to work without im.close exception
Hum... Not so good. No error message but no image at all
Your Document or Test3 document?
My document. I'm checking with the test3
Same behavior: no image at all chapter3.xlsx
ok, this is strange. My one looks like: chapter3.xlsx
C:\local\pyreqif\reqif2xlsx.py C:\local\pyreqif\someFolder\chapter3.reqif C:\local\pyreqif\chapter3.xlsx
Which is correct except the superimposed image.. You have updated iss9 ?
where do you have a superimposed image?
In line 4, you have two different images, superimposed.
Anyway, it seems we have different behaviors. Mine never stops in xslx lines 30 and 32. Therefore, no image.
Priblem at line rtfFilename = urllib.parse.unquote(rtfFilename) and then goes to except.
chapter3.xlsx ok, did not see this - now multiple pictures in one cell are one above the other...
Congratulations ! This works perfectly. However I have commented the im.close() at line 56, otherwise it crashes on this im.close(). I do not understand why. That's a very valuable script. Thanks a lot for this ReqIf to Excel. I did enjoy to cooperate with you. Perhaps an excel to ReqIf ? Sounds feasable. Challenging.
.... well reading images from excel is not easy - at least with the usual python libs ... The other things might definitively be possible
... @laurentcabot
some attempt for xlsx to reqif is done in branch: xlsx_to_reqif
OK. Trying....
That's a nice module and it works fine. Anyway the requirements hierarchy is lost. All items are at the same level. Is there any way to keep the ReqIf hierarchy ?