Is there a way to get all embedded objects in .xlsx file using xssf event mdel api - apache-poi

Is there a way to get all embedded objects in .xlsx file using xssf event model api?
Usermodel has the method workbook.getallembedds...similarly is there anything in eventmodel?
This is an example in usermodel.I want to implement the same functionality using eventusermodel.Kindly help.
for (PackagePart pPart : workbook.getAllEmbedds()) {
String contentType = pPart.getContentType();
if (contentType.equals(------)
Instead of xssfworkbook(in usermodel), in the eventmodel code i have a containerObject of type OPCPackage.
#Gagravarr : Thanks for your reply. I tried using the method suggested by you...but im unable to get the contents of the embedded excel.Could you please help me find out where I am going wrong.Here is a part of the code:
ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(container);
XSSFReader xssfReader = new XSSFReader(container);
XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator)xssfReader.getSheetsData();
for(PackageRelationship rel : iter.getSheetPart().getRelationshipsByType(XSSFRelation.OLEEMBEDDINGS.getRelation()))
embedds.add(getTargetPart(rel));
for (PackagePart pPart :getAllEmbedds()) {
String contentType = pPart.getContentType();
// Excel Workbook - OpenXML file format
if (contentType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml")) {
OPCPackage excelObject = OPCPackage.open(pPart.getInputStream());
`

Your best bet is probably just to enumerate all the package parts, and find the ones that interest you from that
Alternately, the logic to identify embedded parts attached to a given sheet is pretty simple:
List<PackagePart> embedds = new LinkedList<PackagePart>();
// Get the embeddings for the workbook
for(PackageRelationship rel : sheet.getSheetPart().getRelationshipsByType(XSSFRelation.OLEEMBEDDINGS.getRelation()))
embedds.add(getTargetPart(rel));
for(PackageRelationship rel : sheet.getSheetPart().getRelationshipsByType(XSSFRelation.PACKEMBEDDINGS.getRelation()))
embedds.add(getTargetPart(rel));
return embedds;

Finally all I used was this!
ArrayList<PackagePart> parts = container.getParts();
for (PackagePart pPart :parts) {
String contentType = pPart.getContentType();
if (contentType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {

Related

NotesException: Unknown or unsupported object type in Vector

I'm trying to add new names to the address book programmatically but I'm getting the following error:
[TypeError] Exception occurred calling method NotesDocument.replaceItemValue(string, Array)
Unknown or unsupported object type in Vector
Code snippet below:
var addressBook = session.getDatabase("","names.nsf");
var gView:NotesView = addressBook.getView("($VIMGroups)");
var gDoc:NotesDocument = gView.getDocumentByKey("groupName", true);
var newg:java.util.Vector = [];
var mems:java.util.Vector = new Array(gDoc.getItemValue('Members'));
newg.push(mems);
var newNames:java.util.Vector = new Array(getComponent("NewMems").getValue());
newg.push(newNames);
gDoc.replaceItemValue("Members", newg);
gDoc.save();
Adding a single user works fine, but then it does not save users in the required canonical format below:
CN=John Doe/O=Org
Instead it is saved in the original format below:
John Doe/Org
I look forward to your suggestions. Thanks.
You can't store an Array in a field. Make newg a java.util.Vector instead and integrate with that.
For OpenNTF Domino API the team wrote a lot of code to auto-convert to Vectors, which may cover Arrays.
Don't use an Array (which is a JS thing). Initialize it as a Vector.
var newg:java.util.Vector = new java.util.Vectory();
Then look up the Vector methods to see how to add to that vector. Not sure if you will have to convert the names using the Name method but I would store them as "CN=Joe Smith/O=Test Org" to be sure you got the right format.
I was able to solve the issue using a forloop to loop through the list and push it into a newly created array. Using the forloop seems to make the difference.
var newg = [];
var group = new Array(getComponent("NewMems").getValue()), lenGA = group.length;
for(i = 0; i < lenGA; i++){
newg.push(group[i]);
}
gDoc.replaceItemValue("Members", newg);
gDoc.save();
An explanation about this behaviour will be appreciated.

How to extract lists from Sharepoint which includes the attacthments

Any idea's on how to extract a list (not Library's) from Sharepoint that includes the attachments.
When i extract to excel the attachments column just says YES or NO but no actual copy or link to the attachment.
Any help would be greatly appreciated.
The property you need to use is SPListItem.Attachments (documentation)
Since you haven't provided any code to work from I've had to make a simple example. I would suggest posting the code you're working on in future, you will receive much better replies.
using (var objSite = new SPSite("http://sharepointsite"))
{
using (var web = objSite.OpenWeb())
{
var objlist = web.Lists["Testing List"];
var objItem = objlist.GetItemById(1);
var attachments = objItem.Attachments;
}
}

Get FileDownloadUrl from attachment (Agile PLM)

I've been following the code samples included in Oracle document E15930_01 (Agile PLM Core Web Services User Manual). The samples are in Java, but I've translated what I need to .NET for the project I'm working on.
I can search for an object and return its attachments. I can get all the attachment properties except the one I need, fileDownloadUrl. This field is always blank.
Sample code follows. I thought by setting the property of allFiles to false and downloadUrl to true, I should get a download URL, but I don't. This code returns all the properties for the attachment except the one I want. Any thoughts on what I'm doing wrong?
AttachmentService svc = new AttachmentService();
svc.Credentials = credentials;
AgileGetFileAttachmentRequest[] req2 = InitializeArray<AgileGetFileAttachmentRequest>(1);
AgileFileAttachmentRequestType[] attachments = InitializeArray<AgileFileAttachmentRequestType>(1);
req2[0].classIdentifier = "MyIdentifier";
req2[0].objectNumber = "1234567890";
req2[0].allFiles = false;
req2[0].downloadUrl = true;
req2[0].attachments = attachments;
attachments[0] = new AgileFileAttachmentRequestType();
int rowId = getRowId(tt);
attachments[0].rowId = rowId;
GetFileAttachmentRequestType get = new GetFileAttachmentRequestType();
get.requests = req2;
GetFileAttachmentResponseType resp2 = svc.getFileAttachment(get);
AgileFileAttachmentResponseType[] attchResp = InitializeArray<AgileFileAttachmentResponseType>(1);
attchResp = resp2.responses[0].attachment;
Posting this in case someone else needs to do this or I need to do it later.
I found the data I needed. The download URLs are generated based on XML values in several fields in the database. They're the folder name, filename and FolderVersion on the row you're looking at. You need to parse the XML and retrieve the values to generate the link.
You can get the pattern for the download link through the Get Shortcut button.

ActionScript. Can't get data from local xls file

I want to get data from xls file with help of as3xls.
private var file:FileReference = new FileReference();
private var sheet:Sheet;
private var loadedFile:ByteArray;
private function sendLogistImport():void {
file.addEventListener(Event.SELECT, onFileSelect);
file.browse();
file.addEventListener(Event.COMPLETE,
function (e:Event):void {
loadedFile = e.currentTarget.data as ByteArray;
var excelFile:ExcelFile = new ExcelFile();
excelFile.loadFromByteArray(loadedFile);
sheet = excelFile.sheets[0];
Alert.show(sheet.getCell(1,0).value);
}
);
}
private function onFileSelect(e:Event):void {
file.load();
}
But I get this error at the excelFile.loadFromByteArray(loadedFile);:
Error: Error #2030: End of file was encountered.
at flash.utils::ByteArray/readUTFBytes()
at com.as3xls.xls::ExcelFile/boundsheet()[/Users/manuelwudka-robles/Documents/Flex Builder 3/as3xls/com/as3xls/xls/ExcelFile.as:633]
at Function/http://adobe.com/AS3/2006/builtin::call()
at com.as3xls.xls::ExcelFile/loadFromByteArray()[/Users/manuelwudka-robles/Documents/Flex Builder 3/as3xls/com/as3xls/xls/ExcelFile.as:309]
at Function/<anonymous>()[D:\logist.as:244]
This is my xls file's screenshot :
Here is my xls file:
http://www.filedropper.com/template_1
Please tell me, where is my mistake?
I've tested it with various XLS formats, and it can't read any of them. Judging from the comments, the support for the various XLS formats is rather bad.
Try it with different XLS formats, maybe you find one that works, other than that I'm afraid I can't help you, fixing the problem in the library is a monstrous task, and I wouldn't touch it with a ten-foot pole: http://www.openoffice.org/sc/excelfileformat.pdf
Also check out some of the forks around the net, like for example https://github.com/djw/as3xls, they may have some fixes implemented that get you going.
And if nothing work for you, then I'd suggest to look for another library, and/or even use a totally different file format (like CSV) if that is an option.

Reading Signature lines using OpenXMlSDK

I just started office development and have been trying to read a word 2013 document that holds signature fields in it using open xml sdk
can some one help me how to do that.
using (var document = WordprocessingDocument.Open(#"D:\Temp_Folder\tempfile.docx", false))
{
var docPart = document.MainDocumentPart;
}
I have tried reading word file using ELdos (SBOffice) I can get signature lines but not able to get full details related to Signature Lines like Suggested Signer and Suggested Signer email.
Can some one suggest me which I have to prefer OpenXMLSDK or Eldos(SBOffice) bcz i need to find signature fields and then sign them by custom certificate using Third party Signing Service.
The best way would be to use the OpenXMLSDKTool to open the document and it will show you the code necessary to replicate it. I believe it would be within a shape something like
using (var document = WordprocessingDocument.Open("YourDoc.docx", false)
{
var signature = document.MainDocumentPart.Document.Descendant<DocumentFormat.OpenXML.VML.Office.SignatureLine>().FirstOrDefault();
var suggestedSigner = signature.SuggestedSigner;
var suggestedSignerTitle = signature.SuggestedSigner2;
var suggestedSignerEmail = signature.SuggestedSIgnerEmail;
}
You could get the actual signature image in this same area.

Resources