Let $R$ be a commutative ring. Let $U\subseteq X:=\operatorname{Spec}(R)$ be an arbitrary open subset. Let $S$ be the multiplicative set of elements of $R$ which don't vanish anywhere on $U$. Explicitly, $U$ is open so by definition there exists some ideal $I\subseteq R$ such that $U$ is the prime ideals of $R$ which don't contain $I$, and then $S$ is the complement of the union of these prime ideals.
If $A:=\mathcal{O}_X(U)$ is the value of the structure sheaf at $U$, then restriction of functions gives us a map $R\to A$ and the image of every $s\in S$ is invertible in $A$ (because locally invertible) so we get a map $R[1/S]\to A$.
What is an example where this map is not an isomorphism of rings? I have no reason to believe that it is an isomorphism in general, but (a) if $U=D(f)$ (that is, $I=(f)$) then it is an isomorphism, and (b) if $X$ is affine 2-space over a field $k$ and $U$ is the complement of the origin -- the canonical "non-affine open in an affine" -- then $S$ is the non-zero constants and $R[1/S]=k[x,y]=A$. I need to expand my mental store of examples/counterexamples to answer this one, I think. Can someone help?
An even easier example than the two current answers is the following. (See also this MO answer.)
Example. Let $E$ be an elliptic curve over an algebraically closed field $k$. Let $O \in E(k)$ be the origin, and $P \in E(k)$ a non-torsion point. Let $X = E \setminus \{O\}$ and $U = X \setminus \{P\}$.
If $f \in S$ (i.e. $f \in R = \Gamma(X,\mathcal O_X)$ becomes invertible on $U$), then $\operatorname{div}(f) \subseteq E$ has to be supported on $\{O,P\}$. Because $P$ is non-torsion, the only way this can happen is if $\operatorname{div}(f) = 0$, i.e. $f \in k^\times$. We conclude that $S = R^\times = k^\times$, so $R[1/S] \cong R$. But $\Gamma(U,\mathcal O_U)$ is not isomorphic to $R$. $\square$
This is the canonical "affine open that is not standard affine open".