transfer surplus electricity in the house to power grid
how can I get output for the amount of electricity transferred by the power generator from the grid?
If you have, for instance, excess PV generation (with or without storage), this would show up in the eplustbl.htm file under "Electric Loads Satisfied", as illustrated here. Compare "Electricity Coming From Utility" vs "Surplus Electricity Going To Utility". The latter seems to be what you're after (based on the title of your question).
If the "Electricity Coming From Utility" is 0 (or nearly), then the PV kit (array/inverter/distribution/storage) is sufficient to render the building model "off-grid". If the PV kit is instead insufficient, EnergyPlus will draw from the utility to meet demands, as explained here and here (search for "All demand not met by available generator capacity (or storage) will be met by purchased electrical").
You may find this paper of some interest.
EDIT: Add the following to an .idf file to get monthly tallies of "Electricity Coming From Utility" vs "Surplus Electricity Going To Utility"
Output:Variable,
*, !- Key Value
Facility Total Purchased Electricity Energy, !- Variable Name
Monthly; !- Reporting Frequency
Output:Variable,
*, !- Key Value
Facility Total Surplus Electricity Energy, !- Variable Name
Monthly; !- Reporting Frequency
Look up the last 12 occurrences of each output variable in the generated .eso file.
@sheida, I edited my initial answer (to get monthly tallies).
Based on what you said I got these results, but my big question is that, why although we have surplus energy made by PV we have have electricity coming from utility yet?!(/upfiles/17013812497317174.png)
From your June results, one can clearly see evenings/nights/mornings when there's electricity consumption in the home (when the PV array isn't generating); if storage is inadequate (size, charge/discharge characteristics), E+ will necessarily draw from the utility (possibly a virtual utility if the house is meant to be off-grid). You can track storage outputs. Either reconsider storage parameters, or constrain loads when it's dark.
A side note: It would be preferable to EDIT your initial question (similar to how I edited my initial answer), than to ask a follow-up question as an answer. Something to consider in the future.
@sheida, does the sum of monthly "Facility Total Surplus Electricity Energy" not match the annual "Surplus Electricity Going To Utility"? Make sure it does before moving on. Repeat the exercise (on an hourly basis), for a month where the home is actually drawing electricity from the grid (NOT June, maybe e.g. December?). For the hours when the house is drawing from the utility, compare demand vs PV VAC generation vs storage discharge vs utility - they should add up.