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 the 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<Sheet>().Where(s => s.Name == "Sheet1").SingleOrDefault<Sheet>();
We are able to read the same file if we first open it using MS Excel and save. Does anyone know how to resolve this?
You probably forgot to give your sheet a name. You can see this by using
Sheet sheet = workbookPart.Workbook.Descendants<Sheet>().FirstOrDefault
and you'll see that your sheet name is either undefined or garbage text.
If that does not help. Create a simple document in code save it in OOXML and open it in a xml viewer. then make a copy open it in Excel and save it and see the difference in xml. That is often a good start seeing what excel has added by default to the document.
Excel is very tolerant of things that you have done wrong when creating the document in code, and magically fix them when you open the document again.
A bad hack would be using interop to open the document saving it again in code. wich would fix everything for you.
Workbook wrkbk = app.Workbooks.Open(#"c:\del.xls");
wrkbk.Save();
wrkbk.Close();
Related
In Excel I can read data from another cell in a closed spreadsheet that is on Sharepoint Online by using this formula.
='https://mycompany.sharepoint.com/sites/Site/Shared Documents/[Excel.xlsx]Sheet'!A1
It doesn't visibly open any workbooks files to get this information.
How do I get the data using VBA, say to set a string value. Every guidance I have seen involves Workbooks.open but I think it shouldn't be necessary to open the workbook?
I am using SpreadsheetML to generate an Excel spreadsheet with multiple worksheets.
I would like to make the document read only when opened with Excel. How can I do this?
(I appreciate that a user could open the XML file as text and do what they want with it so this is read-only in the loosest sense.)
Thanks
Spreadsheet ML references:
https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats#Excel_XML_Spreadsheet_example
http://m8y.org/Microsoft_Office_2003_XML_Reference_Schemas/Help/html/spreadsheetml_HV01151864.htm
https://en.wikipedia.org/wiki/SpreadsheetML
Im trying to open a specific excel sheet from my PPt-slide using "insert>>object".
So my Excel Workbook is calling " mape1", and in this Workbook here are many sheets, and I want to open a specific one called "sheet1".
I gave the following pfad in the "object"
As Example
C:\Users\me\Desktop\mappe1\sheet1.xls
But it doesn't work
what am I missing?
Thank you for your help
Check out this support article from Microsoft I've linked below. It says by using the insert method you will bring in "all data from the active, top spreadsheet in the linked Excel workbook."
I suggest copy and pasting the selection you want into PowerPoint as is described here:
https://support.office.com/en-us/article/Import-data-from-Excel-into-PowerPoint-3ec295e9-1bfd-47ff-8d7d-8b838caef853#__toc241650191
I recently made an Excel workbook (with the help of Stackoverflow) where I have a regular input of data (each entry is one row with different columns). I then have a macro that extracts the data from a specified row to a different sheet and saves this sheet as a .PDF.
That way, I can extract specific data from this Excel "database" to a readable pdf. I do this because I need a paper version from specific entries.
For a different project I need to implement the same principle. The only difference is that I need to work with an .mdb file where the data is stored, instead of an Excel workbook.
Is there a way I can reuse my code from Excel or is it now a completely different story?
Thank you for the advice.
You can link your excel workbook to your Access tables. On the "DATA" ribbon there is a section for "External Data".
Once you've got the Access data displayed on one of your worksheets, you should be able to adapt your existing code accordingly.
From Microsoft:
Connect an Access database to your workbook
I have some customer MS Excel VBA code (MS Excel 2007) that takes a range as input and then does some work on it (it is quite a large range). I want to use a separate excel document as the source of the range data. If I have both the source and target document open then the function works just fine. If I have only the target document open I get #Value! returned and stepping through in the debugger I see "Error 2023" in the data value passed in. Any ideas how I make this work without having to open both spreadsheets simultaneously?
I am not sure if I have understood the problem correctly; as you have mentioned that there are 2 excel spreadsheets viz source and target and since you would be referring both you should have both the spreadsheets open.
Are you looking for a solution to open the reference spreadsheet automatically?
Cheers... Nilesh