Expansion of the derivatives of the electric and magnetic fields

Let's see if the following helps.

First, we don't need to worry about the expansions of $E$ and $H$ themselves; we are told they exist and are of the form

$$ E(z,t)= \sum_{n=0}^\infty A_n(t) \sin(k_nz) \\ H(z,t)= \sum_{n=0}^\infty H_n(t) \cos(k_n z), $$

whatever the coefficients $A_n(t)$ and $H_n(t)$ are (they have been computed using the formulas you mention).

Now, we want to expand their derivatives. Let's start with the electric field:

$$ \frac{\partial E(t,z)}{\partial z} = \frac{B_0(t)}{2} + \sum_{n=1}^\infty B_n(t)\cos (k_n z), $$

(the electric field is odd, so its derivative is even, thus the cosines) where the coefficients $B_n(t)$ are computed as we know (as the theorem you have posted tells us):

$$ B_n(t)=\frac{2}{L} \int_{-L}^0 \frac{\partial E(t,z)}{\partial z} \cos (k_nz) dz.$$

I mean $B_n(t)$ and not $A_n(t)$ because, for the momment, we are expanding $\partial E/\partial z$ as if we knew nothing about $E(t,z)$. Suppose that $\partial E/\partial z$ is a function $f(t,z)$ and we expand it.

For $n\neq 0$, the integral above is computed by parts:

$$ \int_{-L}^0 \frac{\partial E(t,z)}{\partial z} \cos (k_nz) dz= E(t,z)\cos(k_nz)\bigg|_{-L}^0 - \int_{-L}^0 E(t,z)\frac{d}{dz}\cos(k_n z)= E(t,z)\cos(k_nz)\bigg|_{-L}^0 + \sum_{m=0}^\infty k_n\int_{-L}^0 A_n(t)\sin(k_m z) (z,t)\sin(k_nz)dz = E(t,z)\cos(k_nz)\bigg|_{-L}^0 - A_n(t)k_n\frac{L}{2} $$

(you can see the computations here ($m\neq n$) and here ($m=n$), so that it results:

$$B_n(t)= \frac{2}{L}\left(E(t,z)\cos(k_nz)\bigg|_{-L}^0 + k_n\frac{L}{2}\right). $$

Now let's compute $B_0$:

$$ B_0(t)=\frac{2}{L}\int_{-L}^0 \frac{\partial E(t,z)}{\partial z}dz = \sum_{n=0}^\infty k_n \int_{-L}^0 A_n(t)\cos(n\pi z/L)dz = 0 $$

(answer here.

Hence:

$$ \frac{\partial E(t,z)/\partial z} = \frac{B_0(t)}{2} + \sum_{n=1}^\infty B_n(t)\cos(n\pi z/L) =\sum_{n=1}^\infty \frac{2}{L}\left(E(t,z)\cos(k_nz)\bigg|_{-L}^0 + k_n\frac{L}{2}\right)\cos(n\pi z/L). $$

There is one missing detail, something I do not really understand. For $n>0$, the result for $B_n(t)$ involves $E(0,t)$ and $E(t,-L)\cos(-n\pi)$. If we use the series to compute $E(t,-L)$, we get a zero, so that term vanishes, so it would not appear in the final expression, that is OK. But the same should happen to $E(t,0)$. So check the boundary conditions and see what the values of $E(t,0)$ and $E(t,-L)$ are.

The magnetic field seems to follow the same procedure, although you can check that the result is exactly the same as if we computed the derivative $\partial H/\partial z$ directly. Be careful because in doing so we are igonoring the boundary conditions at $z=0,-L$. Compute $\partial H/\partial z$ using both approaches and check that indeed they agree.