I inserted an image to .docx file by using Apache POI.But When I open the created word file then its showing me the error "the document file can not be opened because there is some problem with the contents." Although I can see the image in the created word file.Please help me to get rid of this.
Related
I'm trying to implement a Node.js file server using the webdav-server npm module which works perfectly.
I'm able to open, edit and save .docx files with Microsoft Word (Microsoft® Word 2016 MSO (16.0.14228.20216) 32-Bit). As well as .odt files with LibreOffice Writer (Version: 7.0.6.2 (x64))
Capturing the requests made by Microsoft Word or LibreOffice Writer I detect the expected order GET - LOCK - PUT - UNLOCK representing the requests made by opening a file (GET), deactivating the readonly mode (LOCK), saving some changes (PUT) and closing the text editor application (UNLOCK).
However if I want to edit and save a .doc file with my Mircosoft Word application I see that there is not PUT request when saving the changes and therefore the changes are lost on closing the application. There is no feedback of any kind through MS Word when clicking the save button. Not that it saved the changes nor that it didn't.
On the other hand when I open the .doc files with LibreOffice Writer there is a PUT request as I'd expected it to be.
I also tried to switch the file type in the MS Word settings so it should use .doc to save files instead of .docx (default with MS Word 2016) but that didn't change anything.
Anyone knows what the problem could be? I don't get why the PUT request should not be sent by Microsoft Word for the .doc file type but for the .docx file type?
(It's a requirement of the project that it also works with .doc files, in the best case with LibreOffice and MS Word)
Thank you all in advance!
I have done quite a bit of searching before posting this question so let me outline what I am trying to do.
1.) I do not want to use applications I have to download from a website or created custom commands (please no start Xls2Csv.exe here's a link to a website where you can download the program) I do not want to download a program to do this.
2.) I want to keep it in the batch file if possible - I have tried the vbc/vbs/vb files that is not what I am looking for.
3.) I found this an this is close to what I need but if I can stay within a batch file that would be best: Can a Batch File Tell a program to save a file as? (If so how)
Background
I have a bunch of test records stored in excel sheets within folders. Each test record has autoformatted name so the only real difference between any of the filenames is a serial number, otherwise each file name is formatted the exact same way.
I have written a batch file to search and find the files I need but I am stuck on obtaining a tiny bit of information in a .xls file.
What I am trying to do - I have excel files (.xls) and there is a word in a cell on one of many sheets that I would like to copy into a textfile. However I am unable to use findstr for an excel find because the command searches the file as if you opened it in notepad and the data I need is not present.
I am not concerned of data loss as long as I can get this tiny bit of information to a text file.
Otherwise what I have found to be the best solution is to convert an XLS to a CSV. I have manually done it by opening the file and saving as type .csv that worked.
What hasn't worked is:
example1.xls >> example2.csv
ren example1.xls example3.csv - this will save it as a csv file but still opens with the same formating of the xls file in both excel and notepad.
I was hoping that the was a command to recreate the manual process of opening the file and saving as csv.
If there are any other suggested solutions - maybe a command where I can search for a string within an excel file? That would be the simplest option.
I am exploring PDF file format and trying to edit and manipulate its internal data. the problem is that I noticed I always get corrupted files after making any minor change to a file so I tried a very simple example to just read the pdf data and rewrite it to a new "file.pdf" without making any changes, as follows:
file = open('sample.pdf','r',encoding='ansi').read()
file_ = open('output.pdf','w').write(file)
but again I got a corrupted file (can't be opened using Adode reader) so I tried to open it using Google Chrome and it worked properly but with the font has changed to the default instead of the original font file.
I opened the input and output files and compared them using notebad++ and two files matched exactly!
I also opened the output file and copied its content and pasted it to the input file and surprisingly, it worked well, exactly as the input file.
Any ideas what is the problem?
I copy-pasted content from webpages into an Excel file in various sheets.
Saving the file took a long time and I realised that the file size had grown to 6mb.
When I open the file Excel crashes.
Is there any way to remove all objects through VBA from some other Excel file or a suggestion how I can solve this issue?
You can view the xml structure of an XLSX by converting it to a ZIP archive.
Look for the images in: /xl/media/
As mentioned in your comment, ActiveX content is in \xl\activeX
I downloaded an xls file from a website and I need to convert to csv for further parsing . I used a 3rd party library to do this, But the xls file doenst open as it. But after I open the file in excel and saving it manually, it works. I am not sure what is happening. can somebody let me know how to write a c# code to open xls in Excel and enable saving , save it and close it?. If I can do this programtically I am all set.