For completeness, I will work through the entire problem so it can benefit others who view the post. To find, the Fourier coefficients we use
\begin{align}
a_0 &= \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}d\theta\\
&= \frac{\pi^2}{12}\\
a_n &= \frac{1}{\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}\cos(n\theta)d\theta\tag{1}\\
&= \frac{1}{n^2}
\end{align}
where the solution to $(1)$ comes about from integration by parts twice. Thus,
$$
f(\theta) = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{\cos(n\theta)}{n^2}
$$
Now, we can use the exponential form of the Fourier series, $\sum_{n=-\infty}^{\infty}c_ne^{in\theta}$.
\begin{align}
c_n &= \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}e^{-in\theta}d\theta\\
&= \cdots\\
&= \frac{1}{4\pi ni}\Bigl[\frac{-2\pi}{in} + \frac{e^{-in\theta}}{n^2}\Bigr|_0^{2\pi}\\
&= \frac{1}{2n^2}
\end{align}
That was for $c_n$ when $n\neq 0$ since we would have $\frac{1}{2\cdot 0}$ if zero was included. When $n = 0$, $e^{-in\theta} = 1$ so the integral is
$$
c_0 = \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}d\theta = \frac{\pi^2}{12},
$$
Now, we have that
$$
f(\theta) = \frac{(\pi - \theta)^2}{4} = \underbrace{\frac{\pi^2}{12}}_{c_0\text{ term}} + \underbrace{\sum_{n\neq 0}\frac{e^{in\theta}}{2n^2}}_{\sum_{n =1}^{\infty}\frac{e^{in\theta}}{2n^2}+\sum_{n =1}^{\infty}\frac{e^{-in\theta}}{2n^2}} = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{\cos(n\theta)}{n^2} \tag{2}
$$
So we now have $\sum_{n =1}^{\infty}\frac{e^{in\theta}}{2n^2}+\sum_{n =1}^{\infty}\frac{e^{-in\theta}}{2n^2}$. Since $\cos$ is even, $\cos(x) = \cos(-x)$ so $e^{in\theta} + e^{-in\theta}=2\cos(n\theta)$ which leads to the desired cosine series.
In the exponential Fourier series, the $c_0$ term is accounted for by $\frac{\pi^2}{12}$ so the exponential series is for $n\in\mathbb{Z}\setminus\{0\}$. If we let $\theta = 0$ in $(2)$, we have
$$
\frac{\pi^2}{4} = \frac{\pi^2}{12} + \underbrace{\sum_{n\neq 0}\frac{1}{2n^2}}_{2\sum_{n=1}^{\infty}\frac{1}{2n^2}} = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{1}{n^2}
$$
Taking the RHS and the last equality, we have
\begin{align}
\frac{\pi^2}{4} &= \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{1}{n^2}\\
\sum_{n=1}^{\infty}\frac{1}{n^2} &= \frac{\pi^2}{6}
\end{align}
For completeness, I will work through the entire problem so it can benefit others who view the post. To find, the Fourier coefficients we use \begin{align} a_0 &= \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}d\theta\\ &= \frac{\pi^2}{12}\\ a_n &= \frac{1}{\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}\cos(n\theta)d\theta\tag{1}\\ &= \frac{1}{n^2} \end{align} where the solution to $(1)$ comes about from integration by parts twice. Thus, $$ f(\theta) = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{\cos(n\theta)}{n^2} $$ Now, we can use the exponential form of the Fourier series, $\sum_{n=-\infty}^{\infty}c_ne^{in\theta}$. \begin{align} c_n &= \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}e^{-in\theta}d\theta\\ &= \cdots\\ &= \frac{1}{4\pi ni}\Bigl[\frac{-2\pi}{in} + \frac{e^{-in\theta}}{n^2}\Bigr|_0^{2\pi}\\ &= \frac{1}{2n^2} \end{align} That was for $c_n$ when $n\neq 0$ since we would have $\frac{1}{2\cdot 0}$ if zero was included. When $n = 0$, $e^{-in\theta} = 1$ so the integral is $$ c_0 = \frac{1}{2\pi}\int_0^{2\pi}\frac{(\pi - \theta)^2}{4}d\theta = \frac{\pi^2}{12}, $$ Now, we have that $$ f(\theta) = \frac{(\pi - \theta)^2}{4} = \underbrace{\frac{\pi^2}{12}}_{c_0\text{ term}} + \underbrace{\sum_{n\neq 0}\frac{e^{in\theta}}{2n^2}}_{\sum_{n =1}^{\infty}\frac{e^{in\theta}}{2n^2}+\sum_{n =1}^{\infty}\frac{e^{-in\theta}}{2n^2}} = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{\cos(n\theta)}{n^2} \tag{2} $$ So we now have $\sum_{n =1}^{\infty}\frac{e^{in\theta}}{2n^2}+\sum_{n =1}^{\infty}\frac{e^{-in\theta}}{2n^2}$. Since $\cos$ is even, $\cos(x) = \cos(-x)$ so $e^{in\theta} + e^{-in\theta}=2\cos(n\theta)$ which leads to the desired cosine series. In the exponential Fourier series, the $c_0$ term is accounted for by $\frac{\pi^2}{12}$ so the exponential series is for $n\in\mathbb{Z}\setminus\{0\}$. If we let $\theta = 0$ in $(2)$, we have $$ \frac{\pi^2}{4} = \frac{\pi^2}{12} + \underbrace{\sum_{n\neq 0}\frac{1}{2n^2}}_{2\sum_{n=1}^{\infty}\frac{1}{2n^2}} = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{1}{n^2} $$ Taking the RHS and the last equality, we have \begin{align} \frac{\pi^2}{4} &= \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{1}{n^2}\\ \sum_{n=1}^{\infty}\frac{1}{n^2} &= \frac{\pi^2}{6} \end{align}