He is also accused of leaving a backpack containing explosives in a classroom.
The suspect, identified only as Jakub Z. under Polish privacy laws, could face life in prison over offences involving the attempted murder of multiple people using explosives, prosecution spokeswoman Elżbieta Edyta Łukasiewicz said.
A request to remand him in custody for three months was due to be filed with a court.
The suspect is in his final year at the school.
He is accused of attacking five fellow students, two teachers and two other people on Wednesday morning.
He also faces charges relating to the attempted murder of two passers-by outside the school and making death threats against two employees, whom he allegedly chased through a corridor with a knife.
One teacher remains in hospital.
Prosecutors said a teacher and 11 students were in the classroom where the backpack was left.
When smoke began coming from it, someone threw it out of a window.
Police bomb-disposal experts detonated the device on Thursday.
The spokeswoman said it had significant destructive power.
The suspect was detained shortly after the attack, near a municipal beach, not far from the school.
He had inflicted injuries on himself and was taken to hospital.
A breathalyser test was negative.
A blood sample was taken to test for alcohol and psychoactive or intoxicating substances.
He admitted guilt, according to Łukasiewicz, but she said his explanations did not address the substance of the case or the acts he had been charged with.
The spokeswoman said investigators believed he had acted alone so far.
Police searched three locations, including his home, on Wednesday evening.
A chemical precursor that could have been used to make explosives was found, the spokeswoman added.
His phone and computers have been seized for detailed analysis.
Additional police patrols have been deployed in Ostrołęka, particularly near schools.
Students were also due to attend preventive sessions with psychologists and police officers on Friday, focusing on how to respond to potential threats and the risks posed by the internet.
Łukasiewicz urged the public not to spread unverified or false information, saying it was causing unnecessary anxiety.
Meanwhile, on Thursday, a 15-year-old former student attacked three people at a school in the village of Leszczydół-Nowiny, near the town of Wyszków, some 50 km northeast of Warsaw, killing a 37-year-old school employee and injuring two others.
(ał/gs)
Source: PAP