Search Results

Search found 30 results on 2 pages for 'ooxml'.

Page 1/2 | 1 2  | Next Page >

  • Use SSIS to populate Excel workbook generated using OOXML

    - by Maulik
    We are trying to generate MS Excel workbook using OOXML and populate data using SSIS. We are able to generate Workbook and sheets, also able to create columns and insert data in Header cell. We can also populate data using SSIS. But the Sheet (DocumentFormat.OpenXml.Spreadsheet.Sheet) and all cells (DocumentFormat.OpenXml.Spreadsheet.Cell) becomes OpenXmlUnknownElement. So we are not able to read sheet / cell using following Code. Sheet sheet = workbookPart.Workbook.Descendants().Where(s = s.Name == "Sheet1").SingleOrDefault(); We are able to read the same file if we first open it using MS Excel and save.

    Read the article

  • Dealing With Table Borders In OOXML

    - by Tim Murphy
    Note: Cross posted from Coding The Document. Permalink Formatting tables in a document programmatically can be a very complex task.  This is the major reason which we start our document generation projects with templates instead of building components in a document by hand. Borders are on aspect of a table that you may want to fomat.  Borders are used to make certain content in a table stand out.  If you need to conditionally set and remove borders there is something that you need to be aware of.  Even in OOXML you have the concepts of styles, inheriting styles and overriding styles. When Word defines a table it will reference a global style such as “TableGrid”.  This style will include the borders for the table.  Specifically the InsideHorizontalBorder and InsideVerticalBorder define the borders for the cells.  These can be overridden by the TableCellBorders collection of a particular cell.  Adding a double right border on a cell is as easy as the couple of lines of code below. wordprocessing.TableCellBorders borders = new wordprocessing.TableCellBorders(); borders.RightBorder = new RightBorder(){Val = BorderValues.Double, Color = "000000", ThemeColor = ThemeColorValues.Text1, Size = (UInt32Value)4U, Space = (UInt32Value)0U }; cell.TableCellProperties.Append(borders); If I want to revert back to the table’s style for cell borders I simply need to remove all children from the TableCellBorders collection.  It is like removing a class identifier from a TD tag in HTML.  The style in the parent object takes back over. With the knowledge of how the borders work you can take the concept and apply it to other effects of styles. del.icio.us Tags: OOXML,Office Open XML,Microsoft Office 2007,Microsoft Word 2007,table,style,border

    Read the article

  • Save Powerpoint 2007 as Powerpoint 2003 using Open Office SDK 2.0

    - by user299592
    Is there anyway to use the Open Office SDK 2.0 to save a powerpoint presention that you created using OOXML to a Office 2003 powerpoint presentation? I know if you open a 2007 file and click Save As you have the option to save it as a Powerpoint 97 to 2003 document and I didn't know if I could do this grammatically using this SDK. The reason I am asking this question is because I need to give the user the option to save data on a website in either office 2007 or 2003 format. I much rather just use the same code to produce the document instead of having to have two code paths for powerpoint 2003 and powerpoint 2007.

    Read the article

  • Word 2007, Open XML - embedding an image

    - by agnieszka
    Do you know what basic information MUST include a paragraph (w:p) in document.xml inside a *.docx document, that specifies an image? I do know there must be <a:blip r:embed="rId4" /> specifing the relation id, but what else? It's very hard to find it in google and experimenting with cutting out tags from a ready document or reading the specification takes a lot of time. An example with all the required tags would be greatly appreciated.

    Read the article

  • Open XML SDK 2.0 - Split table to new power point slide when content flows off current slide

    - by amurra
    I have a bunch of data that I need to export from a website to a power point presentation and have been using Open XML SDK 2.0 to perform this task. I have a power point presentation that I am putting through Open XML SDK 2.0 Productivity Tool to generate the template code that I can use to recreate the export. On one of those slides I have a table and the requirement is to add data to that table and break that table across multiple slides if the table exceeds the bottom of the slide. The approach I have taken is to determine the height of the table and if it exceeds the height of the slide, move that new content into the next slide. I have read Bryan and Jones blog on adding repeating data to a power point slide, but my scenario is a little different. They use the following code: A.Table tbl = current.Slide.Descendants<A.Table>().First(); A.TableRow tr = new A.TableRow(); tr.Height = heightInEmu; tr.Append(CreateDrawingCell(imageRel + imageRelId)); tr.Append(CreateTextCell(category)); tr.Append(CreateTextCell(subcategory)); tr.Append(CreateTextCell(model)); tr.Append(CreateTextCell(price.ToString())); tbl.Append(tr); imageRelId++; This won't work for me since they know what height to set the table row to since it will be the height of the image, but when adding in different amounts of text I do not know the height ahead of time so I just set tr.Heightto a default value. Here is my attempt at figuring at the table height: A.Table tbl = tableSlide.Slide.Descendants<A.Table>().First(); A.TableRow tr = new A.TableRow(); tr.Height = 370840L; tr.Append(PowerPointUtilities.CreateTextCell("This"); tr.Append(PowerPointUtilities.CreateTextCell("is")); tr.Append(PowerPointUtilities.CreateTextCell("a")); tr.Append(PowerPointUtilities.CreateTextCell("test")); tr.Append(PowerPointUtilities.CreateTextCell("Test")); tbl.Append(tr); tableSlide.Slide.Save(); long tableHeight = PowerPointUtilities.TableHeight(tbl); Here are the helper methods: public static A.TableCell CreateTextCell(string text) { A.TableCell tableCell = new A.TableCell( new A.TextBody(new A.BodyProperties(), new A.Paragraph(new A.Run(new A.Text(text)))), new A.TableCellProperties()); return tableCell; } public static Int64Value TableHeight(A.Table table) { long height = 0; foreach (var row in table.Descendants<A.TableRow>() .Where(h => h.Height.HasValue)) { height += row.Height.Value; } return height; } This correctly adds the new table row to the existing table, but when I try and get the height of the table, it returns the original height and not the new height. The new height meaning the default height I initially set and not the height after a large amount of text has been inserted. It seems the height only gets readjusted when it is opened in power point. I have also tried accessing the height of the largest table cell in the row, but can't seem to find the right property to perform that task. My question is how do you determine the height of a dynamically added table row since it doesn't seem to update the height of the row until it is opened in power point? Any other ways to determine when to split content to another slide while using Open XML SDK 2.0? I'm open to any suggestion on a better approach someone might have taken since there isn't much documentation on this subject.

    Read the article

  • Open XML document ContentControls problem with signed id's

    - by willvv
    I have an application that generates Open XML documents with Content Controls. To create a new Content Control I use Interop and the method ContentControls.Add. This method returns an instance of the added Content Control. I have some logic that saves the id of the Content Control to reference it later, but in some computers I've been having a weird problem. When I access the ID property of the Content Control I just created, it returns a string with the numeric id, the problem is that when this value is too big, after I save the document, if I look through the document.xml in the generated document, the <w:id/> element of the <w:sdtPr/> element has a negative value, that is the signed equivalent of the value I got from the Id property of the generated control. For example: var contentControl = ContentControls.Add(...); var contentControlId = contentControl.ID; // the value of contentControlId is "3440157266" If I save the document and open it in the Package Explorer, the Id of the Content Control is "-854810030" instead of "3440157266". What have I figured out is this: ((int)uint.Parse("3440157266")).ToString() returns "-854810030" Any idea of why this happens? This issue is hard to replicate because I don't control the Id of the generated controls, the Id is automatically generated by the Interop libraries.

    Read the article

  • YASR - Yet another search and replace question

    - by petronius31
    Environment: asp.net c# openxml Ok, so I've been reading a ton of snippets and trying to recreate the wheel, but I'm hoping that somone can help me get to my desination faster. I have multiple documents that I need to merge together... check... I'm able to do that with openxml sdk. Birds are singing, sun is shining so far. Now that I have the document the way I want it, I need to search and replace text and/or content controls. I've tried using my own text - {replace this} but when I look at the xml (rename docx to zip and view the file), the { is nowhere near the text. So I either need to know how to protect that within the doucment so they don't diverge or I need to find another way to search and replace. I'm able to search/replace if it is an xml file, but then I'm back to not being able to combine the doucments easily. Code below... and as I mentioned... document merge works fine... just need to replace stuff. protected void exeProcessTheDoc(object sender, EventArgs e) { string doc1 = Server.MapPath("~/Templates/doc1.docx"); string doc2 = Server.MapPath("~/Templates/doc2.docx"); string final_doc = Server.MapPath("~/Templates/extFinal.docx"); File.Delete(final_doc); File.Copy(doc1, final_doc); using (WordprocessingDocument myDoc = WordprocessingDocument.Open(final_doc, true)) { string altChunkId = "AltChunkId2"; MainDocumentPart mainPart = myDoc.MainDocumentPart; AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart( AlternativeFormatImportPartType.WordprocessingML, altChunkId); using (FileStream fileStream = File.Open(doc2, FileMode.Open)) chunk.FeedData(fileStream); AltChunk altChunk = new AltChunk(); altChunk.Id = altChunkId; mainPart.Document.Body.InsertAfter(altChunk, mainPart.Document.Body.Elements<Paragraph>().Last()); mainPart.Document.Save(); } exeSearchReplace(final_doc); } protected void exeSearchReplace(string document) { using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) { string docText = null; using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart. GetStream())) { docText = sr.ReadToEnd(); } Regex regexText = new Regex("acvtClientName"); docText = regexText.Replace(docText, "Hi Everyone!"); using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create))) { sw.Write(docText); } } } } }

    Read the article

  • In Powerpoint 2007, how can I position a Callout's Tail programatically?

    - by Rorschach
    I'm looking at the XML and this is what it has for the Callout object's coordinates and geometry: <p:spPr> <a:xfrm> <a:off x="2819400" y="5181600"/> // X,Y Position of Callout Box <a:ext cx="609600" cy="457200"/> // Width,Height of Callout Box </a:xfrm> <a:prstGeom prst="wedgeRectCallout"> <a:avLst> <a:gd name="adj1" fmla="val 257853"/> // X Position Of Tail <a:gd name="adj2" fmla="val -532360"/> // Y Position of Tail </a:avLst> </a:prstGeom> <a:solidFill> <a:schemeClr val="accent1"> <a:alpha val="50000"/> </a:schemeClr> </a:solidFill> </p:spPr> What I'm having trouble with is the formula for telling it to place the tail at a particular coordinate on the slide. I've tried this to calculate it, but it does not work correctly. //This gives me the distance between the Coordinate and the Center of the Callout. DistanceX = Coordinate.X - (Callout.X + Callout.X_Ext)/2 DistanceY = Coordinate.Y - (Callout.Y + Callout.Y_Ext)/2 But, the geometric value is not the distance between the two points. Anybody know what the formula is for calculating this?

    Read the article

  • Speaking At The Chicago Code Camp

    - by Tim Murphy
    I just got news that my talk on Office Open XML has been accepted for the Chicago Code Camp.  I hear that they will be announcing the full schedule of sessions soon.  Be sure to register and join us.  As a bonus the guys from .NET Rocks will be there. http://www.chicagocodecamp.com del.icio.us Tags: .NET Rocks,Chicago Code Camp,Speaking,OOXML SDK 2.0,OOXML,Office Open XML,PSC Group

    Read the article

  • June LCNUG Presentation

    - by Tim Murphy
    Office Open XML has been my focus for the last 8 months.  We are creating  solutions that generate data and business rule heavy presentations and document.  On June 24th I will be covering the how to use OOXML to generate documents that can be used as sales and marketing collateral.  Register below and come out and join the discussion. http://www.eventbrite.com/event/722041646 del.icio.us Tags: Office Open XML,OOXML PSC Group,LCNUG,Document Generation

    Read the article

  • Update Since Microsoft/PSC Office Open XML Case Study

    - by Tim Murphy
    In 2009 Microsoft released a case study about a project that we had done using the OOXML SDK 1.0 for Research Directors Inc.  Since that time Microsoft has released version 2.0 of the SDK and PSC has done significant development with it.  Below are some of the mile stones we have reached since the original case study. At the time of the original case study two report types had been automated to output as PowerPoint presentations.  Now that the all the main products have been delivered we have added three reports with Word document outputs and five more reports with PowerPoint outputs. One improvement we made over the original application was to create a PowerPoint Add-In which allows the users to tag a slide.  These tags along with the strongly typed SDK 2.0 allows for the code to use LINQ to easily search for slides in the template files.  This allows for a more flexible architecture base on assembling a presentation from copied slide extracted from the template. The new library we created also enabled us to create two new Word based reports in two weeks.  The library we created abstracts the generation of the documents from the business logic and the data retrieval.  The key to this is the mark up.  Content Controls are a good method for identifying sections of a template to be modified or replaced.  Join this with the concept of all data being generically either scalar or two dimensional and the code becomes more generic. In the end we found the OOXML SDK 2.0 to be a great tool for accelerating document generation development and creating happy clients.  del.icio.us Tags: PSC Group,OOXML,Case Study,Office Open XML,Word,PowerPoint

    Read the article

  • how to concatenate two strings in shell script in 3.13.0-34-generic kernel

    - by saikrishna
    I want to concatenate two strings for the shell file im getting error when i have created the shell file in following manner could you please suggest how to get it set export APP_HOME="/home/sfptladmin/ArchivalDaemon" export JAVA_HOME="/usr/lib/jvm/java-7-oracle/jre" export LIBPATH="/home/sfptladmin/ArchivalDaemon/lib" export CPATH=$APP_HOME/conf export CPATH=$CPATH:$LIBPATH/commons-beanutils-core-1.7.0.jar export CPATH=$CPATH:$LIBPATH/commons-collections-3.2.jar export CPATH=$CPATH:$LIBPATH/commons-io-1.4.jar export CPATH=$CPATH:$LIBPATH/commons-lang.jar export CPATH=$CPATH:$LIBPATH/commons-net.jar export CPATH=$CPATH:$LIBPATH/dataloader-27.0.1-uber.jar export CPATH=$CPATH:$LIBPATH/dom4j-1.6.1.jar export CPATH=$CPATH:$LIBPATH/log4j-1.2.15.jar export CPATH=$CPATH:$LIBPATH/opencsv2.3.jar export CPATH=$CPATH:$LIBPATH/poi-3.7.jar export CPATH=$CPATH:$LIBPATH/poi-ooxml-3.7.jar export CPATH=$CPATH:$LIBPATH/poi-ooxml-schemas-3.7.jar export CPATH=$CPATH:$LIBPATH/wsc-23-min.jar export CPATH=$CPATH:$LIBPATH/xmlbeans-2.5.0.jar export CPATH=$CPATH:$LIBPATH/archival-daemon-main.jar export CPATH=$CPATH:$LIBPATH/sbmclasspath.jar export CPATH=$CPATH java -Xms256m -Xmx512m -classpath $CPATH "-Dfile.encoding=UTF-8" com.genpact.proflow.daemon.archival.manager.ArchivalManager echo $CPATH

    Read the article

  • Chicago Architects Group &ndash; Document Generation Architectures

    - by Tim Murphy
    Thank you to everyone who came out to the Chicago Architects Group presentation last night.  It seemed like the weather has a way of keeping a large portion of the people who registered from making the meeting.  There was some lively networking going on before and after the meeting.  I enjoyed the questions that people had during the presentation.  It helped to bring out some of the challenges with dealing with the OOXML and ODF standards from an architecture perspective. I have posted the Slides and Code.  Feel free to contact me with any questions. For those of you who missed the presentation I will be giving a similar one at the Lake County .NET Users Group on June 24th. The next CAG presentation will be July 20th.  The presentation will be Architecting A BI Installation by David Leininger.  Look for the registration to open in the next day or so. del.icio.us Tags: Chicago architects Group,OOXML,ODF,BI,LCNUG,slides,code

    Read the article

  • java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.POIXMLDocument on Jboss 5.0 EAP

    - by nidhin
    Getting following exception in Jboss 5.0 EAP but it work fine in JBoss 5.1 GA. we are using POI 3.7 and jars included are poi-3.7.jar poi-ooxml-schemas.jar poi-ooxml.jar The stack trace is ERROR [org.apache.catalina.core.ContainerBase.[jboss.ueb].[localhost].[fesbcon-Fig].[Faces Servlet]] 3;13;44.4g3pM (http-0.0.0.0-8280-1) Servlet.service() -For servlet Faces Servlet threu exception java.lang.NoClassDe-FFoundError: Could not initialize class org.apache.poi.POIXMLDocument at org.apache.poi.ss.usermodel.HorkbookFactory.create(HorkbookFactory.java:62) at com.-Ferguson.esb.con-Fig.controller.AssociationsExcelUploadController.submit(Unknoun Source) at sun.re-Flect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.re-Flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.re-Flect.DelegatingMethodAccessorImpl.invoke(Delegating?ethodAccessorImpl.java:25) at java.lang.re-Flect.Method.invoke(Method.java:597) at org.apache.my-Faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132) at org.apache.my-Faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61) Please Advise how to solve this issue in JBoss 5.0 EAP

    Read the article

  • Unable to use XSSF with Excel 2007

    - by Tarun
    Hello All, I am having tough time getting to read data from excel 2007. I am using XSSF to read data from a specific cell of excel but keep getting error - Exception in thread "main" java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions; at org.apache.poi.POIXMLDocumentPart.(POIXMLDocumentPart.java:46) This is my piece of code - public static void main(String [] args) throws IOException { InputStream ins = new FileInputStream("C:\\Users\\Tarun3Kumar\\Desktop\\test.xlsx"); XSSFWorkbook xwb = new XSSFWorkbook(ins); XSSFSheet sheet = xwb.getSheetAt(0); Row row = sheet.getRow(1); Cell cell = row.getCell(0); System.out.println(cell.getStringCellValue()); System.out.println("a"); } I have following jars added to build path - poi-3.6 poi-ooxml-3.6 poi-ooxml-schemas-3.6 x-bean.jar I could only figure out that "setSaveAggressiveNamespaces" has replaced "setSaveAggresiveNamespaces"....

    Read the article

  • Where I Am Speaking Soon

    - by Tim Murphy
    Open XML and document generation has been my focus lately.  With that being the case I will be speaking on the subject in the near future at the following event. Chicago Code Camp – May 1 Chicago Architects Group – June 15 Lake Count .NET User Group – June 17 I hope to see you at one (or more) of these events. del.icio.us Tags: speaking,Office Open XML,OOXML,Document Generation

    Read the article

  • Chicago Code Camp Recap

    - by Tim Murphy
    My presentation on leveraging Open XML was a great experience and the attendees were very gracious.  I was pleasantly surprised to have a full room.  There was even one person sitting on the floor.  You can check out some pictures here.  I have posted my slides and code.  If anyone has any feedback or questions feel free to contact me. del.icio.us Tags: Chicago Code Camp,OOXML SDK 2.0,Office Open XML,slides,code

    Read the article

  • Setting classpath and installing database via batch file

    - by Supereme
    Hi, I want my classpath to be set via a batch file. I'm working on Windows XP. I have two questions: My first question: I made a batch file in which I typed "set classpath = C:\WINDOWS\system32\;.;C:\jdk1.5.0\lib\tools.jar;C:\poi-3.6\poi-3.6-20091214.jar;C:\poi-3.6\poi-contrib-3.6-20091214.jar;C:\poi-3.6\poi-ooxml-3.6-20091214.jar;C:\poi-3.6\poi-ooxml-schemas-3.6-20091214.jar;C:\poi-3.6\poi-scratchpad-3.6-20091214.jar;E:\jdbc\postgresql-8.2-505.jdbc3.jar;C:\xmlbeans-2.5.0\lib\jsr173_1.0_api.jar;C:\xmlbeans-2.5.0\lib\resolver.jar;C:\xmlbeans-2.5.0\lib\xbean.jar;C:\xmlbeans-2.5.0\lib\xbean_xpath.jar;C:\xmlbeans-2.5.0\lib\xmlbeans-qname.jar;C:\xmlbeans-2.5.0\lib\xmlpublic.jar;C:\dom4j-1.6.1\dom4j-1.6.1.jar; exit" When I tried to run this file it ran but when I went into control panel systemadvancedenvironment variables and then selected classpath, it didn't show me the classpath I did set. What is the correct way to set the classpath via batch file? My second question: Is there any way by which we can install database via batch file say for eg: postgresql8.2? Thank you.

    Read the article

  • 2011 Chicago Code Camp

    - by Tim Murphy
    It is that time again.  Time to polish up you presentation skills on your favorite language or technology features.  The Chicago Code Camp is accepting proposals for presentations.  Show everyone in the Chicago area what you know and submit your own. I really enjoyed presenting last year and just had to submit a proposal for this year.  This time around my topic is Increasing Collaboration with Windows Phone 7, SharePoint 2010 and Office Open XML.  I had a much longer title but the site forced me to shorten it up.  I guess that is a good way to tell people not to get too wordy. If you don’t feel like presenting mark the date and come out and enjoy the company of your fellow geeks and learn about some new technologies. http://chicagocodecamp.com/ del.icio.us Tags: Chicago Code Camp,speaking,WP7,Windows Phone 7,SharePoint 2010,OOXML,Office Open XML

    Read the article

  • ODF (Open Document Format) para ISVs - 16/Dez/10

    - by Paulo Folgado
    Os ISVs (Independent Software Vendors) sentem frequentemente necessidade de incluir nas suas aplicações uma funcionalidade de exportação de informação - uma carta, uma tabela com dados financeiros, um gráfico, etc - para que possa ser trabalhada externamente com ferramentas ditas de Produtividade num 'desktop' (também designadas por 'Suites de Office'). Nessas situações são confrontados com a necessidade de elegerem que formato deve ser usado para essa exportação de dados, sendo a escolha mais usual a utilização dos formatos do Microsoft Office. Contudo, se fôr essa a sua única opção, estarão a auto excluir-se de um mercado em crescimento constituído pelos clientes que utilizam outras ferramentas de produtividade, nomeadamente as que são baseadas no standard ISO Open Document Format (ODF), como é o caso do Open Office. Este seminário tem por objectivo dar aos parceiros ISVs da Oracle: Uma visão sobre o mercado actual de 'suites' de Office e dos standards usados pelos principais fornecedores de soluções A estratégia da Oracle para o Open Office Razões para deverem suportar a norma ODF Como suportar ODF nas suas aplicações Agenda O mercado actual das Suites Office Os standards actuais "de facto" e oficiais - MS-Office, OOXML e ODF Que produtos usam o ODF hoje Estratégia Oracle para o Open Office Porquê suportar ODF nas aplicações Como adaptar as aplicações actuais à utilização de ODF Local: Oracle - Lagoas ParkData: 16 de DezembroDuração: 1/2 diaHorário: 9:30 - 12:00 Inscrições: Email, ou pelo telefone 211929708 Para mais informações, por favor contacte Claudia Costa via Email ou telefone 214235027.

    Read the article

  • Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException

    - by Dheeraj kumar
    Hi, I have to read xls file in java.I used poi-3.6 to read xls file in Eclipse.But i m getting this ERROR"Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException at ReadExcel2.main(ReadExcel2.java:38)". I have added following jars 1)poi-3.6-20091214.jar 2)poi-contrib-3.6-20091214.jar 3)poi-examples-3.6-20091214.jar 4)poi-ooxml-3.6-20091214.jar 5)poi-ooxml-schemas-3.6-20091214.jar 6)poi-scratchpad-3.6-20091214.jar Below is the code which i m using: import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import java.io.FileInputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.ArrayList; public class ReadExcel { public static void main(String[] args) throws Exception { // // An excel file name. You can create a file name with a full path // information. // String filename = "C:\\myExcel.xl"; // // Create an ArrayList to store the data read from excel sheet. // List sheetData = new ArrayList(); FileInputStream fis = null; try { // // Create a FileInputStream that will be use to read the excel file. // fis = new FileInputStream(filename); // // Create an excel workbook from the file system. // // HSSFWorkbook workbook = new HSSFWorkbook(fis); Workbook workbook = new XSSFWorkbook(fis); // // Get the first sheet on the workbook. // Sheet sheet = workbook.getSheetAt(0); // // When we have a sheet object in hand we can iterator on each // sheet's rows and on each row's cells. We store the data read // on an ArrayList so that we can printed the content of the excel // to the console. // Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { Row row = (XSSFRow) rows.next(); Iterator cells = row.cellIterator(); List data = new ArrayList(); while (cells.hasNext()) { Cell cell = (XSSFCell) cells.next(); data.add(cell); } sheetData.add(data); } } catch (IOException e) { e.printStackTrace(); } finally { if (fis != null) { fis.close(); } } showExelData(sheetData); } private static void showExelData(List sheetData) { // // Iterates the data and print it out to the console. // for (int i = 0; i < sheetData.size(); i++) { List list = (List) sheetData.get(i); for (int j = 0; j < list.size(); j++) { Cell cell = (XSSFCell) list.get(j); System.out.print(cell.getRichStringCellValue().getString()); if (j < list.size() - 1) { System.out.print(", "); } } System.out.println(""); } } } Please help. thanks in anticipation, Regards, Dheeraj!

    Read the article

  • Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException

    - by Dheeraj kumar
    I have to read xls file in java.I used poi-3.6 to read xls file in Eclipse.But i m getting this ERROR"Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException at ReadExcel2.main(ReadExcel2.java:38)". I have added following jars 1)poi-3.6-20091214.jar 2)poi-contrib-3.6-20091214.jar 3)poi-examples-3.6-20091214.jar 4)poi-ooxml-3.6-20091214.jar 5)poi-ooxml-schemas-3.6-20091214.jar 6)poi-scratchpad-3.6-20091214.jar Below is the code which i m using: import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import java.io.FileInputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.ArrayList; public class ReadExcel { public static void main(String[] args) throws Exception { // // An excel file name. You can create a file name with a full path // information. // String filename = "C:\\myExcel.xl"; // // Create an ArrayList to store the data read from excel sheet. // List sheetData = new ArrayList(); FileInputStream fis = null; try { // // Create a FileInputStream that will be use to read the excel file. // fis = new FileInputStream(filename); // // Create an excel workbook from the file system. // // HSSFWorkbook workbook = new HSSFWorkbook(fis); Workbook workbook = new XSSFWorkbook(fis); // // Get the first sheet on the workbook. // Sheet sheet = workbook.getSheetAt(0); // // When we have a sheet object in hand we can iterator on each // sheet's rows and on each row's cells. We store the data read // on an ArrayList so that we can printed the content of the excel // to the console. // Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { Row row = (XSSFRow) rows.next(); Iterator cells = row.cellIterator(); List data = new ArrayList(); while (cells.hasNext()) { Cell cell = (XSSFCell) cells.next(); data.add(cell); } sheetData.add(data); } } catch (IOException e) { e.printStackTrace(); } finally { if (fis != null) { fis.close(); } } showExelData(sheetData); } private static void showExelData(List sheetData) { // // Iterates the data and print it out to the console. // for (int i = 0; i < sheetData.size(); i++) { List list = (List) sheetData.get(i); for (int j = 0; j < list.size(); j++) { Cell cell = (XSSFCell) list.get(j); System.out.print(cell.getRichStringCellValue().getString()); if (j < list.size() - 1) { System.out.print(", "); } } System.out.println(""); } } } Please help. thanks in anticipation, Regards, Dheeraj!

    Read the article

1 2  | Next Page >