I am working on creating excel sheet using PHP Excel. Excel sheet is creating fine and there are no errors while creating excel sheet. This excel sheet has some formulas on few columns as well as some cells has dropdown list (values for these list are saved in seperate tab).
Now, When I open this sheet, then MS Excel is showing me message that:
Excel found unreadable content in abc.xlsx. Do you want it to recorver?
After click YES button, MS Excel shows me another dialog box in which it describes the recover process. Please check the below screenshot of that 2nd dialog box.
After recovering excel sheet is opened. But I am not able to get what was unreadable or corrupted content into this sheet so that I can fix it.
Below is simple code to create and then download excel sheet nothing else:
$excelname = 'Testing';
$objPHPExcel = new \PHPExcel();
header('Content-Type: application/vnd.ms-excel');
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header('Content-Disposition: attachment;filename="' . $excelname . ' Template.xlsx"');
$objWriter2 = new \PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter2->save('php://output');
With the above code, I am still getting the first message that: Excel found unreadable content in abc.xlsx. Do you want it to recorver? Now, I am very confused about what is wrong into above line of code.
Can anyone please tell me, How can I find what was unreadable or corrupted content into excel sheet?
Thanks
looks like a hardware issue. Create a backup of the disk you are using and consult your IT dpt specialists.
Related
I am trying to make a button with VBA which automatically creates a screenshot of my dashboard presented in my worksheet and saves it as a separate JPG file.
I am using a Mac with Excel version 16.67.
The idea is that the button is able to do the following:
The button should select the range D4:AG175.
The file must be in JPG.
The location of the file could be in the same map as where the
Dashboard document is located (or on the Desktop, also fine).
The name of the file should be "='Filter Employee Week'!B2" + "='Filter
Employee Week'!B1" + ".jpg"
The "'Filter Employee Week'!B1 and B2" is a name selected from a slicer, which is connected to a pivot table.
So in summary:
The button takes a screenshot of the dashboard in the range D4 to AG175, it must be saved as a JPG in the same folder as the dashboard and the name should idyllically be the name of the employee selected in B2 and B1 (which are imported from a pivot table on a different sheet but presented by a connected slicer).
Can anyone help me with this code? I tried different codes from other users with problems that are comparable to this one, however, I can not get it fixed myself.
I am not able to solve this problem with the solutions presented at this question myself:
Using Excel VBA Macro To Capture + Save Screenshot of Specific Area In Same File
Save captured screenshot as JPG with vba
I'm working with a list of addresses in excel 365. I want to perform a reverse geocode function to produce addresses from the available longitude and latitude info. to do this I have found an excel addin https://github.com/gramener/geocode-excel , which I downloaded. you can see an example in the screenshot above. the formula which it introduces is:
=#NominatimReverseGeocode(B32,C32)
Now what I want to do is make this available in my main sheet so that I can use the NominatimReverseGeocode. I've gone to File - Options - File - Add Ins
But the function 'NominatimReverseGeocode' does not show up in my main sheet. How can I make this function available in my main sheet?
EDIT:
I renamed the file to geocode.xlam in powershell. Now I'm getting:
If your intent is to make the Geocode functions available in all of your workbooks on your computer, do this:
Delete all previously saved Geocode.xlsm and Geocode.xlam files.
Download Geocode.xlsm.
Open it.
Go to File > Save As.
Change the file type from Excel Macro-Enabled Workbook (*.xlsm) to Excel Add-in (*xlam).
Click Save.
Close all instances of Excel.
Open Excel. (i.e. just the Excel application, so not opening a workbook.)
You should be on the Home screen.
Go to New > Blank workbook.
In the ribbon go to Developer > Excel Add-ins.
Check Geocode.
Click OK.
Close all instances of Excel.
Open any Excel workbook or make a new blank workbook.
Put =#NominatimReverseGeocode(51.5,-0.144) in any cell.
This should resolve to the Buckingham Palace Garden.
If your intent is to just have the geocode functions in one specific workbook, let me know and I'll write up the steps for that.
If you only need this code available for yourself and not other users by far the simplest way would be to create a personal macro workbook.
Create a workbook and save it as
C:\Users\username\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.xlsm
Copy the code from the GeoCode workbook into PERSONAL.xlsm.
PERSONAL.xlsm will autoload with Excel. Prefix your function call with the workbook name: =PERSONAL.xlsm!#NominatimReverseGeocode(B32,C32)
Scenario, Email received with Excel file (.xls) attached, file contains data (Sheet1) that is not formatted as a table.
Q:
Is there some way using Power Automate to run a script against it to apply transforms?
Ideal outcome would be:
Excel file received as email attachment, delete header rows in Sheet1 (rows 1 and 2), save as CSV file and email new file to user.
Thank you for posting the question.
There are 3 parts to it.
Extracting the email attachment (xls) and saving it as xlsx. Converting xls > xlsx may be possible - but I'm not sure about the exact steps. Are you sure you are getting xls and not xlsx?
Removing header row is possible with Office Scripts. You can try recording your action in Excel for web and use that script. Be sure to change the sheet name as shown below.
function main(workbook: ExcelScript.Workbook) {
let sheet = workbook.getWorksheet('Sheet1');
// This can also be first sheet if you know it'll always be first sheet that you want to operate on.
// let sheet = workbook.getFirstWorksheet();
sheet.getRange("1:2").delete(ExcelScript.DeleteShiftDirection.up);
}
To export as CSV, there seems to be online resources to do refer to: https://www.youtube.com/watch?v=Ik-TLaMByhw&ab_channel=AndersJensen
Good luck and let us know how it worked out.
My client receives an email with a one-time-access url each day (it can only be accessed once, and only on that day).
Content from this url is plain text formatted as a .csv (actually tilda sv) file, but that is not of relevance here.
The content is then (manually) copied and pasted into Excel sheet, where some (formatting) macros are applied (to get rid of tildas and put data into cells).
Also, few of the first rows of the content are irrelevant, i.e. only lines 5-end are copied into Excel.
My question is the following - is it possible to write a VBA in Outlook to
open the url provided in the given email
copy the content from the webpage (and remove those first couple of lines)
open Excel and paste it there (and apply formatting afterwards)
I found some answers on how to copy/paste content from the email itself into Excel sheet, but didn't manage to sort out how to do it from a url/webpage.
Yes it is possible
I am not expert on VBA, but I do little programing to reduce daily task
I can show you the steps:
create rule that triggers VB script when email arrives.
In the VB script in the outlook, write code that would open excel
pass the connection string
set the R1C1 as destination cell
Save the file as date variant .xls
Make sure outlook is open. This would not work if outlook is not open
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();